Something Strange about these submissions that I am unable to understand

Here’s a problem from the famous Atcoder Educational DP Contest: Flowers

AC Solution: Link
RE Solution: Link

I made 2 submissions of this problem one being AC and other giving Runtime Error. The only difference between them was that in the AC Solution, the array for segment tree was declared as global vector and i resized the vector in the local function and in the RE Solution I declared the global vector as an array of size 4*N + 5.

Why is one getting accepted and the other isn’t ?? Any kind of help is appreciated.

1 Like

According to the constraints provided in the question :-

1 ≤ N ≤ 2×10^5

but you have done const int N = 1e5 + 9;.
Change it to const int N = 2e5 + 9; and it should work fine.

1 Like

Thanks a lot man…!! That was stupid of me :neutral_face: