OneClickAC's blog

By OneClickAC, history, 8 years ago, In English

Hi , I am a beginner programmer and i need some help . Basically i was working on a problem on codeforces (Problem Link-> http://codeforces.me/problemset/problem/600/B)(using java) and i am getting TLE verdict. I am not able to understand why i am getting so as I am using map for insertion and retrieval of values which is a form of red black tree and takes logarithmic time . My code is exceeding limit on test 20 .. Submission link->http://codeforces.me/contest/600/submission/23908885

Please help me in understanding the reason behind this and if possible , also tell about how to overcome this problem of Time Limit..

Code Link->http://pastebin.com/tH39VQkR

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

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I got AC by changing int a[]=new int [n]; to Integer a[]=new Integer [n]; check this blog for more details.

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

    Thanks for reminding me..

    • »
      »
      »
      8 years ago, # ^ |
      Rev. 2   Vote: I like it +3 Vote: I do not like it

      Wait what, you was the same person who asked that question? you should definitively diagnose of Alzheimer's.