My approach is this: fix the parameter $x$ from the problem statement and forbid the largest $y$ elements from participating in any operations. In other words, after removing those $y$ largest numbers, choose the largest $\frac{x+1}{2}$ numbers among the remaining elements to contribute to the medians, then perform the allowed operations sequentially from the smallest remaining numbers toward the larger ones until you exhaust the number of operations. Let $f(x,y)$ denote the maximum sum obtainable by this strategy.↵
↵
Next I conjectured that for fixed $y$, letting $g(x)=f(x,y)$, the function $g$ is unimodal. It seems to hold on small examples, but when I submitted I got [**Wrong answer on pretest 4**](https://codeforces.me/contest/2154/submission/344716468).↵
↵
It looks like the unimodality property was wrong, so I instead fixed $x$ and conjectured that $g(y)=f(x,y)$ is unimodal,I submitted another modified version of the code and received [**Wrong answer on pretest 8**](https://codeforces.me/contest/2154/submission/344731626).↵
↵
Just when I didn't know how to debug, a magical idea popped up: concatenate two implementations and take the maximum of their outputs.↵
↵
That's too crazy — you know, I concatenated two approaches that were both known to be wrong, yet in fact, it actually [**passed the problem**](https://codeforces.me/contest/2154/submission/344732130).↵
↵
ig my method can be easily falsified, but I still want to collect hacks here — I hope some contestants can hack this code so the problem's tests get stronger.↵
↵
[new submission](https://codeforces.me/contest/2154/submission/344794124)
↵
Next I conjectured that for fixed $y$, letting $g(x)=f(x,y)$, the function $g$ is unimodal. It seems to hold on small examples, but when I submitted I got [**Wrong answer on pretest 4**](https://codeforces.me/contest/2154/submission/344716468).↵
↵
It looks like the unimodality property was wrong, so I instead fixed $x$ and conjectured that $g(y)=f(x,y)$ is unimodal,I submitted another modified version of the code and received [**Wrong answer on pretest 8**](https://codeforces.me/contest/2154/submission/344731626).↵
↵
Just when I didn't know how to debug, a magical idea popped up: concatenate two implementations and take the maximum of their outputs.↵
↵
That's too crazy — you know, I concatenated two approaches that were both known to be wrong, yet in fact, it actually [**passed the problem**](https://codeforces.me/contest/2154/submission/344732130).↵
↵
ig my method can be easily falsified, but I still want to collect hacks here — I hope some contestants can hack this code so the problem's tests get stronger.↵
↵
[new submission](https://codeforces.me/contest/2154/submission/344794124)




