priyanshu_x's blog

By priyanshu_x, history, 3 years ago, In English

In problem C, I wrote a solution that showed me the wrong answer on test case

For Those who don't know what is problem C
38 
6 9 6 6 6 2 8 6 6 8 5 4 6 6 9 0 0 4 4 3 6 0 0 5 4 5 0 8 4 6 4 8 0 7 5 0 0 8

My first code output 196, AC code output 210

My first code lexicographically largest array

9 8 7 6 9 8 6 8 6 5 4 3 2 0 8 6 5 4 0 8 6 5 4 0 6 5 4 0 6 4 0 6 4 0 6 0 6 0

AC code lexicographically largest array

9 8 7 6 5 4 3 2 0 9 8 6 5 4 0 8 6 5 4 0 8 6 5 4 0 8 6 4 0 6 6 6 4 0 6 0 6 0

I was amazed as I was sure with my logic, but after (successfully wasting more than 1.5 hours) I changed my approach and it got AC. After the contest was over I was thinking why my first solution was wrong and stress tested it. I got a test case

4
2 1 2 3

My first code is giving the lexicographically largest array as 3 2 2 1 whereas my AC code is giving 3 2 1 2, I am completely confused as the first output is better than the second one. Please help!

I am attaching my first code here.

Code

Sorry for my bad English.

Full text and comments »

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