Hoks_'s blog

By Hoks_, history, 11 months ago, In English

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.

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.

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.

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

  • Vote: I like it
  • +98
  • Vote: I do not like it

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Hoks_ (previous revision, new revision, compare).

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I used ChatGPT to revise some of my phrasing and hope it’s easy to understand.

»
11 months ago, hide # |
 
Vote: I like it +42 Vote: I do not like it

Thanks to Kaey for teaching me the skill of merging two wrong solutions (it always works) :))

»
11 months ago, hide # |
 
Vote: I like it +33 Vote: I do not like it

Well I guess two wrongs do make a right

»
11 months ago, hide # |
 
Vote: I like it +88 Vote: I do not like it

Hacked

»
11 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I didn't read the problem and just injected a smarter ternary search in your first solution and it passed first try: 344834569

Which tells that this function is almost ternary, at least in existing tests.

Anyone to hack it?

  • »
    »
    11 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I am running into a very funny issue. If you look at the test case of my recent hack, it gives output of 9220347553542585457 on my machine however on codeforces it gives a different output. Any idea why this is happening?

    • »
      »
      »
      11 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      On my machine the output is 1792169448345 which coincides with codeforces. Exactly which code you are running and what is the compilation command?

      • »
        »
        »
        »
        11 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        This is my build on sublime and I am running your exact submission

        Spoiler
»
10 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Hoks_ (previous revision, new revision, compare).