gsmcoder97's blog

By gsmcoder97, history, 9 years ago, In English

I was solving this problem Snow Sellers (http://codeforces.net/contest/48/problem/F) and I am having problem understanding the idea behind it. If I look at the input test case it is as follows: 2 3 10 4 4 4 5 5 8 1 2 5

According to the question, 2 are the number of days for which the winter goes on(sale); 3 are the number of the snow selling companies; and 10 is the amount of the snow he has to buy everyday exactly(not less and not more).

Now, my understanding is as follows: On the starting of the first day The first company was selling 4 cubic metres for 5 bourles; this means 1 cubic metre for 1.25 bourle. The second company was selling 4 cubic metres for 5 bourles; this means 1 cubic metre for 1.25 bourle. The third company was selling 8 cubic metres for 8 bourles; this means 1 cubic metre for 2 bourles. Thus, to buy 10 cubic metres on the first day, he will buy it from the first or second shop for 12.5 bourles.

On the starting of the second day The first company was selling 4 cubic metres for 4 bourles; this means 1 cubic metres for 1 bourle. The second company was selling 4 cubic metres for 3 bourles; this means 1 cubic metre for 0.75 bourle. The third company was selling 4 cubic metres for 3 bourles; this means 1 cubic metre for 0.75 bourle. Thus, to buy 10 cubic metres on the second day, we will buy it from the second or third shop for 7.5 bourles.

Hence, the total amount is 7.5+12.5=20 bourles.

But, the otuput of the first test case is 22. Please help. Thank you.

  • Vote: I like it
  • +1
  • Vote: I do not like it