Please read the new rule regarding the restriction on the use of AI tools. ×

shubhsy's blog

By shubhsy, history, 6 years ago, In English

Here is my submission and it gives wrong answer for test case 1. It gives an answer of 8 on Codeforces when I submit and 7 when I run it on PC. Can someone help me with that? http://codeforces.me/problemset/submission/1029/42313945

  • Vote: I like it
  • -22
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Try making your arrays global...

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    To elaborate, Global variables are initialized to 0 (for integers) or to similar values for other types. If you define an array locally, it is not initalized and can initially contain whatever.