Getting TLE on "Snake Eating" problem

Problem : CodeChef: Practical coding for everyone
my solution : CodeChef: Practical coding for everyone

learned from : SNAKEEAT | Snack Eating | CodeChef SnackDown 2021 Practice Contest- Beginners | Problem Solution - YouTube

I have followed that youtube tutorial for this problem. Whatever is described, I tried to follow that. He has explained code in python, and I used to code in C++. I did the same thing, but getting TLE.
Please help me to figure out.

Try taking these vectors:

helper(vector<int>vec, vector<lli>prefix,

by reference instead of by value.

1 Like

Now, I am getting wrong answer link
when used,

int helper(vector<int>&vec, vector<lli>&prefix, int k)

and

void solve(vector<int>&vec, int q)

Thank you @ssjgz. Now, my answer is accepted by replacing int by lli.
Thank you again.
Accepted solution link.

1 Like