Hello everyone what the idea to solve this problem I know that it may seems pretty easy problem for you , but for me as a beginer in binary search I couldn't even understand the tutorial !! thank in advance :D
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3657 |
| 3 | jiangly | 3638 |
| 4 | turmax | 3442 |
| 5 | tourist | 3380 |
| 6 | Um_nik | 3353 |
| 7 | strapple | 3350 |
| 8 | squareOf105 | 3346 |
| 9 | heuristica | 3322 |
| 10 | maroonrk | 3310 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | AmShZ | 143 |
| 4 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 134 |
| 9 | maroonrk | 133 |
| 10 | qwexd | 130 |
Hello everyone what the idea to solve this problem I know that it may seems pretty easy problem for you , but for me as a beginer in binary search I couldn't even understand the tutorial !! thank in advance :D
| Name |
|---|



let x by the number that is more repeated after at most k operations , let Fx by the frecuency of x after at most k operations (Fx is the solution to the problem) let A by the array sorted let S by an array where S[i] = A [0] + A [1] +. . . + A[i] is easy to see that x is an element of A whitout make operations, if A[i] = x, then Fx = (i — j + 1) where j is the minimum index where it holds that ( (i — j + 1) * A [i] ) — (S [i] — S [j-1]) <= k, to find j, a binary search is done from [0 .... i].