@swetankmodi You are an observer!
Or perhaps-
4th May 2018 to 14th February, 2019.
I notice how the contest is ending abruptly at Valentines day. Chef will be busy or what?
Very true @mgch . There are usually back to back 3-4 contests in a row that day. Very nice day indeed
XDXDXD.
I’ll do whatever is in my power to stop that XD
never got that opportunity
Solving div2 Questions from div1 will not affect your ratings. In case they do, it will be a bug and you can get opportunity of getting codechef laddus from @admin X)
@l_returns, How did u reduce the given problem to max sum subsequence such that no two adjacent elements are taken? Can u explain in bit detail?
There are multiple issues with your code, i won’t tell you the exact issues. But i would recommend you to clean your code first and use MOD whenever required. Read each expression in your code and ask yourself whether the MOD operation is really required.
One example is this line:
base_f[i] = (base_f[i - 1] % MOD + base_f[i - 2] % MOD) % MOD;
base_f[i - 1] is already smaller than MOD so using another mod just makes it messy.
Once you do that, submit again and if your solution is still failing link back your latest solution in comment and i will help.
Still giving WA on those two cases.
You missed my point, i want you to read each line if your code and remove extra modulo operations. Once you do that you will probably be able to find your mistake. So remove all extra modulo operations first and give link to your cleaned up code.
@vivek_shah98
yeah sure… if I make an element negative then I have to check three conditions…
- Checking if it is greater than the element at right(otherwise sum of these two will become negative).
- Similarly checking if it is greater than left element.
- no assume I have an array like 5 2 3 2 7 then both 2’s follow upper conditions but if make both negative then (-2)+3+(-2) will become negative hence this is the third case which we will have to check(sum of two alternate numbers following above two condition is less than middle element).
If the case is like 2 3 2 3 2 3 2 then we cannot make all 2’s negative. Instead we can imagine an array of 2 2 2 2 (skipping middle elements) and now It reduces to problem of max sum subsequence as if we make elements negative in 2 2 2 2
such that no two are adjacent then 3rd condition will be followed and (-2)+3+2 OR 2+3+(-2) won’t be negative…
If it follows this three conditions then the sum of elements all subarrays having length greater than 1 will be strictly positive…
well i suggest u to check if u r missing any modulo where its needed… if u r multiplying (10^910^910^9)%mod then it would be wrong… u should multiply any two and then multiply further…
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!!