You are not logged in. Please login at to post your questions!


Help in Dynamic Inversion of June Lunchtime

The following solution is accepted as correct solution in the practice link of the question , But when i submitted the same Code during the contest with int inv=0; statement declared outside the while loop it was not accepted , Why??

asked 29 Jun '14, 16:35

mrajesh016's gravatar image

accept rate: 0%

edited 29 Jun '14, 17:23

When you are putting the statement inv=0 , outside the loop , it is not initialised everytime , so it will keep on adding everytime and give wrong answer . For example if for 1st query answer is 1 for second answer is also 1 , if you donot initialise it to zero for the second time , it will give 2 as answer which is wrong . Hope it helps .


answered 29 Jun '14, 17:00

the65bit's gravatar image

accept rate: 13%

edited 29 Jun '14, 17:01

@the65bit is right.. but one more thing inv will be long long not int.. i got WA in 2 cases because of that..


answered 29 Jun '14, 17:30

i_am_what_i_am's gravatar image

accept rate: 10%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 29 Jun '14, 16:35

question was seen: 823 times

last updated: 29 Jun '14, 17:30