We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This approach passed all the test cases of the problem. If you are not getting AC, your implementation might be wrong.
I tested your example in my code. It gave 16 as answer.
The count array after all the calculations will be -> 1 2 3 4 3 2 1
Which I guess is correct.
I am giving the sourcecode.
Candies
You are viewing a single comment's thread. Return to all comments →
This approach passed all the test cases of the problem. If you are not getting AC, your implementation might be wrong.
I tested your example in my code. It gave 16 as answer. The count array after all the calculations will be -> 1 2 3 4 3 2 1 Which I guess is correct. I am giving the sourcecode.
I hope you will get ur mistake
void candies(vector arr, ll n) { ll sumcandy=0; vector up(n, 1); forn(i,n-1) { if(arr[i+1] > arr[i]) up[i+1]=up[i] + 1;
}