Getting wrong answer

Hii…
I am doing this question from codeforces…
This is the question…
https://codeforces.com/problemset/problem/1341/B
I have solved this …pretty much with good logic… But it is showing wrong answer on test case - 2;
This is the solution…
https://codeforces.com/contest/1341/submission/97154154
Please look into this…
Thanks

Hey @ashishnnnnn
Mentioned the changes in comments : https://ide.codingblocks.com/s/365044 :slight_smile:
If this resolves your query then please mark it as resolved :slight_smile:

Here … what and how you have used… i+k-2…
Can you explain this a bit… :slight_smile:

So for segment l to l+k-1 we dont have to consider extremes that is l and l+k-1
So peaksum[ l+k-2 ] contains peaks till that point and peaksum[l] containts peaks till l
Subtracting both will give peaks from l+1 to l+k-2 which is required

Yaa… Thanks…
Got THIS :slight_smile:

1 Like