Блог пользователя dharmang

Автор dharmang, 9 лет назад, По-английски

Here is my code for the problem problem 525B- mysolution . I think I have understood the problem perfectly and coded it but aint able to find what mistake I am making and why i aint getting AC.. Can anyone help?? If you have any other way of solving this you can share that too and if you find a thing or two wrong in my code or concept, please feel free to explain me those!! Thank You guys!! :)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

silly mistake => 10770669

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится +5 Проголосовать: не нравится

    It doesn't matter, you were just lucky :)

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      actually i think i should be very lucky, that in every test case a[] filled with even numbers !!! (somthing like 1/(2^200002) for every test case)

»
9 лет назад, # |
Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

You should initialize your array a with zeroes since it is declared inside the main function: http://mirror.codeforces.com/contest/525/submission/10770670

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Why so ?? If i declare it outside main then does it matter if i initailize it or not?? And can you tell me the reason for the same please!! :)

    • »
      »
      »
      9 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Well, if you declare an array or a variable as global(it is not inside a function) it is initialized with zeroes by default. But if you declare it inside a function(not necessarily inside the main function) it is filled with some random values. What keyvankhademi changed is line 17, but you don't need it, your is correct also. He got AC only because he was lucky :)

      • »
        »
        »
        »
        9 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Thanks man!! And he got lucky because (i am asking) a[i]==1 where i>siz/2 is not present??