|
+3
This line: The conditional is unnecesary, because you can add blocks to the bag while arr[i-1]>arr[i]-k. With that, the sum changes too, the absolute value will generate wrong answer. You should change that line to: |
|
0
When you do the sum m+= k-abs(h2-h1) you are forgetting that the number of blocks of height h1 could be less than k-abs(h2-h1), so when you do that sum, the remaining number of blocks of that pile become negative, and that's impossible. So, the sum is m+=min(h1, k-abs(h2-h1)), and with that the number of blocks will never be negative. |
|
+3
edited |
|
0
You mean s+(t-s)/2 |
|
+1
How much time does it has to pass after the contest is finished to be able to submit a solution of one of the problems? I want to submit my codes for the D1 and D2 problems. |