https://www.codechef.com/viewsolution/33173703
This is my solution for the problem. I am getting WA . Please tell me a testcase where it might be going wrong.Please help.
https://www.codechef.com/viewsolution/33173703
This is my solution for the problem. I am getting WA . Please tell me a testcase where it might be going wrong.Please help.
There are 2 things going wrong in this loop
for(long long int i=0;i<v.size();i++){
if(v[i].second<f){
f=v[i].second;
sum+=(f+1)*g+v[i].first*(f+1);
g=-v[i].first;
}
}
Can you explain what each calculation is doing?
Try the testcase :
5
2 4 3 1 1
Maybe this will help you.
8
0 0 0 0 0
1 1 1 1 1
2 2 2 1 1
You can work this out by hand, you don’t need to ask me.
ok thanks, did it. There was a stupid mistake by me. Thanks for your help.