原创 CodeForces 165B Burning Midnight Oil

One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n li

原创 POJ 2456 Aggressive cows

瘋牛 時間限制:1000 ms  |  內存限制:65535 KB 難度:4 描述 農夫 John 建造了一座很長的畜欄,它包括N (2 <= N <= 100,000)個隔間,這些小隔間依次編號爲x1,...,xN (0

原创 HDU 1166 敵兵佈陣

C國的死對頭A國這段時間正在進行軍事演習,所以C國間諜頭子Derek和他手下Tidy又開始忙乎了。A國在海岸線沿直線佈置了N個工兵營地,Derek和Tidy的任務就是要監視這些工兵營地的活動情況。由於採取了某種先進的監測手段,所以每個工

原创 POJ 3258 River Hopscotch

每年奶牛們都要舉辦各種特殊版本的跳房子比賽,包括在河裏從一塊岩石跳到另一塊岩石。這項激動人心的活動在一條長長的筆直河道中進行,在起點和距離起點 L 遠的終點各有一塊岩石 (1 ≤ L ≤ 10^9)。在起點和終點之間,有 N 塊岩石 (

原创 CodeForces 672D Robin Hood

We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money fro

原创 POJ 3111 K Best

Demy has n jewels. Each of her jewels has some value vi and weight wi. Since her husband John got broke after recent

原创 CodeForces 192A Funky Numbers

As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are repre

原创 POJ 1905 Expanding Rods

When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient o

原创 UVA 714 Copying Books

題意:有一個序列,由m個整數組成,把這個序列劃分爲k個連續的子序列,使得每個子序列和的最大值最小,要求劃分的子序列的和是遞增的,問如何劃分。 關於最大值的最小化問題,我們可以枚舉子序列和的最大值,用二分的方法不斷把最大值縮小,直到最優解,

原创 CodeForces 660C Hard Process

給定一個數組 a,含有 n 個元素。數組 a 中的每個元素要麼是 0,要麼是 1 。 讓我們假定,數組 a 中,僅由數字 1 組成的連續元素所構成的子分段,其最長的長度爲 f(a)。您可以將不超過 k 個 0 更改爲 1,使得 f(a)

原创 POJ 3122 Pie

My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have a number N of them, of variou

原创 CodeForces 165C Another Problem on Strings

A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non

原创 ACdream 1066 Bet

Josnch星球是一個賭博之風盛行的星球。 每個人一出生就有一定數額的錢,之後的所有收入只能由賭博獲得(OMG,如果RP不好,輸光了所有的錢。。。) 假設賭博公司的某場賭博有 N 個結果,每個結果能獲得的賠率比分別是 a[1],a[2

原创 CodeForces 448D Multiplication Table

Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication tabl

原创 HDU 4430 Yukari's Birthday

Today is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most important part, bir