could any one explain the logic for his problem.
i couldn't understand the editorial.
thanks in advance.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 151 |
could any one explain the logic for his problem.
i couldn't understand the editorial.
thanks in advance.
Name |
---|
I haven't read the editorial, my idea was pretty simple. You know before hand the value that each segment should have. Just that sum / 3. And one segment should be a prefix and the other a sufix, now you just notice that if you pick a non overlaping prefix and suffix which sum would be (global_sum / 3) the middle segment also will satisfy this condition. So the problem looks simple now. For every prefix that satisfy the condition count how many suffix starts after the end of this prefix (just preprocess this calculations to do it in O(1)) The sum of this values is the answer to the problem. I hope it will be useful to you. Here is my code: 7952017.