gauravgsmp's blog

By gauravgsmp, history, 4 months ago, In English

My 118th numbers differ in the second testcase of the problem — "Editorial For Two". Can somebody please point the testcase out as I tried my level best but for all random testcases I made, it is showing correct answer. https://codeforces.com/contest/1837/submission/208223724

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 months ago, # |
  Vote: I like it +11 Vote: I do not like it
1
11 6
4 4 5 8 4 10 5 8 5 4 6 

correct output: 13
your output: 14

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

Your approach is a variation of "greedy taking k smallest element". In your case, it is finding the k-th smallest element with value $$$val$$$, then taking the first k elements that is $$$\leq val$$$

This test case kills all solution with that approach (taken from editorial post)

1
4 3
2 3 2 4

The optimal is $$$4$$$ which require taking the biggest value $$$4$$$