submission link :- https://codeforces.me/contest/1369/submission/334063256
problem link :- https://codeforces.me/contest/1369/problem/C
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 144 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 136 |
| 8 | BledDest | 133 |
| 9 | maroonrk | 132 |
| 10 | Proof_by_QED | 131 |
submission link :- https://codeforces.me/contest/1369/submission/334063256
problem link :- https://codeforces.me/contest/1369/problem/C
| Name |
|---|



Didn't read the entier thing but i think your code isn't correct because it keeps puting the biggest numbers into the first not full friend instead of ensuring that each friend gets one of the top k numbers as their owne maximume so some friendes never receive a large max which will lower the total happiness (max + min per friend)
lets take an example input 1
6 2
10 8 0 -1 -3 -4
3 3 Your code form [10,8,0] and [-1, -3,-4] giving (10+0) + (-1-4) = 5.
The optimal answer is to give one big number to each friende and assign the smalest leftovers to fill: maxima 10 and 8 then minima -1 and -4 total 13