Good!
Check these problematic lines
ll x = (b[i] - b[1]) % MOD ;
ll x = (a[i] - a[1]) % MOD;
sum = (1LL * pre_fib[n - 1] % MOD * x * m) % MOD;
Good!
Check these problematic lines
ll x = (b[i] - b[1]) % MOD ;
ll x = (a[i] - a[1]) % MOD;
sum = (1LL * pre_fib[n - 1] % MOD * x * m) % MOD;
gosh!!! now getting WA!! Life is hell!!
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.
welcome 
I don’t know python much but ur algo seems correct…
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.
Never mind. I forgot to loop over the test cases. :))
@rj25 unfortunately, it doesn’t work that way, If you hover over the rank after filtering, it shows you the rank according to filter.
The Indian rank of first person at 107 is 35.
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 am in talks with them. I will update on the issue as and when possible
For April lunchtime? I dont think I have permission to give it out publicly. You can PM/mail if you’re very curious.