Can anybody tell me how to solve Atcoder question Equal cut. The question is Cut the array at 3 positions such that difference of maximum sum of any one part and minimum sum of another part is minimum?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
2 | maomao90 | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Can anybody tell me how to solve Atcoder question Equal cut. The question is Cut the array at 3 positions such that difference of maximum sum of any one part and minimum sum of another part is minimum?
Name |
---|
Quick summary:
Fix the position of the second (middle) cut. Then, the optimal left cut is the one which splits the left side approximately equally (as best as possible). Similarly for the best right cut. This can be found by binary searching on a prefix sum array (or 2-pointers, your preference).
Answer is the minimum across all possible second cuts.
Editorial's out, btw: Here
So according to you we should iterate over all the possible middle position. Then for each middle position we have to split the part to its left and the part to its right almost equally but how can we do that Can you have your code which is explaining your idea.(i.e using binary search).
Exactly. Finding the position to split is done by creating a prefix array of the original array, and binary searching on that.
My code for reference.