afanehkareem's blog

By afanehkareem, history, 4 years ago, In English

Hello Codeforces,

In Round #819 (Div. 1 + Div. 2) today, my solution for problem A turns out it was wrong after the updated tests.

So my first solution was with the picture where b ==> int b=*max_element(arr+1,arr+n);

Picture 1

but after the contest finished i submitted a new solution where b ==> the one with picture where i used a loop.

Picture 2

the first solution failed on test #4, and the second was accepted.

But i really don't understand why the first solution was wrong, or why it didn't pass the updated tests.

Any help!! Thank you all.

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

| Write comment?
»
4 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

notice that n could probably be 1 so your code should run max_element(arr+1,arr+1) and it turns out like random value or something, idk.

  • »
    »
    4 years ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    Yes, I tried it in c++ 14 compiler and gave me a large random value.

    So yes probably that is the reason.

    Thank you for your response.