death_bringer's blog

By death_bringer, history, 17 months ago, In English

My submission 185845851 is getting accepted while another submission 185834138 with the same logic is failed on test case 2.

The only difference is

answer = i;
break;

in accepted vs

answer = min(answer,i);

in failed.

As the value of i is increasing second code line should also give the same output as the first one but it's not.
Please help me where I'm missing something.

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

| Write comment?
»
17 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

In the second submission, you've assigned answer = k before reading the value of k, so answer could be taking any possible initial value such as -100 for example. That would cause wrong answers when taking the minimum.