dominator1234's blog

By dominator1234, history, 4 years ago, In English

I think everybody must be having same problem in Problem D having time limit exceeded on Test case 15. The time limit is too strict for the problem. I am tired of optimizing it further now and I have seen exactly same logic being accepted. I am tired and frustrated now. Somebody pls tell how to optimize it from here on.

Here is my Code:

(https://mirror.codeforces.com/contest/1499/submission/110388552)

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

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

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

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

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

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

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

Just few modifications in your code and it passed in 1044ms.

Code : https://mirror.codeforces.com/contest/1499/submission/110397614

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

    I see so declaring a map do the job. Yeah I thought of that then I just ignored that diff will be not so much in worst case.

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

Can anyone guide me how I can optimize this code. Luckily it just got accepted (Time : 1996 ms).

Link to my code ( Practice )