i checked you recent submission, these lines are still incorrect.
ll x = (b[i] - b[1]) % MOD ; this can go negative so re write it as ll x = (b[i] - b[1] + MOD) % MOD ; and same for the next line.
sum = (1LL * pre_fib[n - 1] % MOD * x * m) % MOD; This can cause integer overflow because you are multiplying 3 integers of magnitude 10^9 so re write it as, sum = (pre_fib[n - 1] * 1LL * x % MOD) * m % MOD;
Check for above two mistakes in full code, hope this helps.
There were lots of conditions involved in that question. But even on missing some, at least some cases passed. Dont know python, but I advise checking up others solution for reference.
It’s a Dynamic Programming problem but you won’t directly reach DP. Realise that two adjacent elements can never be negative. Further an element a[i] can be negative only if a[i-1] > a[i] < a[i+1]. Next if you do above you will get an alternating sequence a[i], a[i+2], a[i+4], … a[i + 2*k] where you have to set some of them to negative such that negative sum is maximized but you can not select two adjacent elements. This is where DP comes into the picture. This another version of the classic DP problem “Maximise the sum of array such that no two elements are adjacent.”.
I meant any updates about May Long Editorials. I saw that only DBFB is out and I read somewhere that the editorialist needs time but that was 2 days ago I think.
I know many people have posted their solutions for some problems but not SERSUM, which is the main reason I’m asking for editorials. I’ll open up a new question if the editorials take too long but it’s better to keep all the discussion about the problem on the editorial page itself. @vijju123
@psaini72 - That DFDB editorial is unofficial one. Because the editorialist for this contest is @triveni (also, the editorialist doesnt mention setter’s solution, name of tester etc.).
Yes, I agree it feels frustrating to you. The same case is with April Lunchtime as well. The editorialist needs more time/is stuck. I am trying my best to make sure something is done about them, and that they arent forgotten.
No use opening a new question tbh. @admin sees it here. I mean, if a I am already working on it, what more can a question do?
I am trying my best for a speedy solution, I assure that