asaecs2's blog

By asaecs2, history, 6 weeks ago, In English
 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by asaecs2 (previous revision, new revision, compare).

»
6 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it
5 1
8 17 1 8 17
  • »
    »
    6 weeks ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    What should be the answer?

    Shouldn't it be 3?

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

      Sorry, I misunderstood your solution at first

      5 1
      32 16 8 4 2
      

      answer is 0 but your code returns 1 because you increment ans if ct==k

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

        thanks a lot man... I did find my mistake.

»
6 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

2 1 $$$\newline$$$ 2 1 $$$\newline$$$ at line 28 of your code, you wrote this : if (ct == k) ans++, ct--; $$$\newline$$$ In case of (k = 1) this will make ans = 1 before entering the loop, meanwhile , in this testcase, the answer is 0. $$$\newline$$$ I suggest doing this instead (at line 28) : $$$\newline$$$ if (k==1){ $$$\newline$$$ cout<<v.size()<<endl; $$$\newline$$$ return; $$$\newline$$$ } $$$\newline$$$