I have tried a lot to solve the "milking cow" problem of USACO . But WA in test 7 . I don't know what is the problem , i have tried multiple approaches , but it still wrong in test 7 . can you please help me to find my bug please ????
my code : https://paste.ubuntu.com/25901070/
problem source : http://train.usaco.org/usacoprob2?a=pxSIvVnwAXn&S=milk2
please please please help me guys , I have tried my best .
Auto comment: topic has been updated by Ahnaf.Shahriar.Asif (previous revision, new revision, compare).
Why are you calling it "serious help"?
sorry for that , but please help me
Well, to help you, I had to solve all of my unsolved problem before this problem to access the problem page you specified.
Ok, I saw your code. You made some mistake in your code. Your code for non_milking is correct.
But in the for loop started at line no 42 you made some mistakes.
1) On line 43, you wrote:
int mxx = ara[i-1].end,mnn = ara[i-1].start;
initializing mxx and mnn asi-1
th value is wrong. You should put this line before the for loop on line and initialize as value of index 0:int mxx = ara[0].end,mnn = ara[0].start;
2) The nested for loop is unnecessary also you made two mistake here:
if(ara[i].start > ara[i-1].end)break;
is wrong since you are keep tracking the max right index in mxx, you should compare the current end with mxx,Also, you incremented i in both of the for loop. After being incremented in the nested for loop, it is again being incremented in the first for loop.
I had modified your code a bit and it got ACCEPTED. Here is the accepted code: code
Thanks a lot brother , I am from Bangladesh , a junior beginner coder (NHSPC contestant) . I have learned a lot from you , I will be grateful to you (i think you are a ICPC contestant ) . I have attended in the last NHSPC camp , I think you were there (may be not , i am not clear )