Why is this code getting RTE? https://ideone.com/fork/KqmvTw The problem statememt: https://cses.fi/problemset/task/1092 Thanks in advance.
# | User | Rating |
---|---|---|
1 | jiangly | 3898 |
2 | tourist | 3840 |
3 | orzdevinwang | 3706 |
4 | ksun48 | 3691 |
5 | jqdai0815 | 3682 |
6 | ecnerwala | 3525 |
7 | gamegame | 3477 |
8 | Benq | 3468 |
9 | Ormlis | 3381 |
10 | maroonrk | 3379 |
# | User | Contrib. |
---|---|---|
1 | cry | 168 |
2 | -is-this-fft- | 165 |
3 | Dominater069 | 161 |
4 | Um_nik | 159 |
4 | atcoder_official | 159 |
6 | djm03178 | 157 |
7 | adamant | 153 |
8 | luogu_official | 151 |
9 | awoo | 149 |
10 | TheScrasse | 146 |
Why is this code getting RTE? https://ideone.com/fork/KqmvTw The problem statememt: https://cses.fi/problemset/task/1092 Thanks in advance.
Name |
---|
I think k — sum1 < 0 for some cases .
Simply do this .
n = 4
1 2 3 4
set1 : 1 4
set2 : 2 3
n = 6
1 2 3 4 5 6
The ans will be no because odd number of pairs .
n = 8
1 2 3 4 5 6 7 8
set1 : 1 8 3 6
set2 : 2 7 4 5
Property of arithmetic progression .
Try taking n as long long. Your code is having integer overflow when you take n >= 1e5
Thanks both so much