4 人解决,7 人已尝试。
9 份提交通过,共有 85 份提交。
8.3 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
A farmer has a set of fields, each of which is surrounded by cypress trees. Also, the farmer has a set of strips of land, each of which has a row of cypress trees. In both fields and strips, between every two consecutive cypress trees is a single olive tree. All of the farmer’s cypress trees either surround a field or are in a strip and all of the farmer’s olive trees are between two consecutive cypress trees in a field or in a strip.
One day the farmer became very ill and he felt that he was going to die. A few days before he passed away he called his eldest son and told him, “I give you any
In Figure 1, assume that the son is given
You are to write a program which, given the information about the fields and the strips and the number of cypress trees the son can pick, determines the largest possible number of olive trees the son may inherit.
The first line contains first the integer
The second line contains
The third line contains
Output contain one line with one integer: the largest possible number of olive trees the son may inherit.
17 3 3 13 4 8 4 8 6
17 Hint: In all inputs, 0<=Q<=150000, 0<=M<=2000, 0<=K<=2000, 3<=Ni<=150 2<=Ri<=150, The total number of cypress trees in the fields and strips is at least Q. Additionally, in 50% of the inputs, Q<=1500.
4 人解决,7 人已尝试。
9 份提交通过,共有 85 份提交。
8.3 EMB 奖励。