https://cses.fi/problemset/result/1601400/
I did Solve It correctly But in Some Test Cases like this
100 1000000
27 69 68 13 1 63 28 44 45 67 5…
It is Creating Vector of 10^8 and giving runtime error Pls Help
https://cses.fi/problemset/result/1601400/
I did Solve It correctly But in Some Test Cases like this
100 1000000
27 69 68 13 1 63 28 44 45 67 5…
It is Creating Vector of 10^8 and giving runtime error Pls Help
You can initialize vector with a fix size like: vectorv(n)
Also do mod of 1e9 + 7 for every dp state to avoid overflow.
You can take reference from here
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.