Please help me in SUMQ

Please help me too, i had made this code for scoring 100 points as per the given constraints. I keep getting WA in some test cases, and i am not able to identify the case. Please help me

https://www.codechef.com/viewsolution/14080761

Thank you.

why don’t you initialize b[0] to 0?

input:

1
15 15 15
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

your output: -204818678

Correct output: 661500

You need to take care of modulo more carefully use parenthesis. Also instead of search function, use upper_bound().
Here is my code with those improvements over yours : https://www.codechef.com/viewsolution/13985909

1 Like

you have problem in your sum equation
consider the 2nd answer in the link below

test cases:

4

3 4 2

1 2 3

5 5 5 5

1 2

3 3 3

1000 1000 1000

10000000 10000000 10000000

1000 1000 1000

3 2 3

1 4 2

5 3

4 5 7

6 6 7

789999 6554 2345556634 16627734 353567334 25555533563

21425525243 1432423 154242434 27622653 343433343 43

10000 100000 10000001 10010100 10000171 7178818 14525526363

1 Like

python 3.4:

https://www.codechef.com/viewsolution/14184513

correct output:

1092

8096220

418

546893310

your output:

1092

8096220

418

382205301

I also want to ask problem in my code for SUMQ. But can’t ask because of lack of Karma points. Help anybody…

1 Like

https://discuss.codechef.com/questions/97820/i-want-to-ask-a-question-ask-them-all-here ask here