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


[closed] Getting TLE in CF round 173 Div 2 B


(I'm a newbie programmer here and this is my first post, so please let me know if I commit any errors in the placement etc of this doubt.)

I have a doubt in Codeforces Round 173 Div 2B - the problem can be found here. My solution (which is getting Time limit exceeded is here. The official solution (seemingly so from the editorial) is here.

My doubts are:

  1. The official solution does not consider any case in which "-1" is the output, seemingly?
  2. My solution seems to be of complexity O(n), but it still gets TLE? Bound of n is 10^6 in the problem.

If someone can help me understand this, thanks a lot! :)

asked 06 Dec '17, 21:49

theoneyouwant's gravatar image

accept rate: 0%

closed 08 Dec '17, 02:33

vijju123's gravatar image

4★vijju123 ♦

Hi, Now I think that there's some issue with the question as when I copy pasted the official solution and submitted, it got TLE as well. I am doing this to complete my A2OJ ladder, is there any other way I can get around this?

(06 Dec '17, 22:06) theoneyouwant4★

The question has been closed for the following reason "User requested" by vijju123 08 Dec '17, 02:33


I think I got my response to the above question - It's because cin and cout aren't fast enough to take input. I needed to use scanf/printf or cin.tie(0) instead. Admin, please close this thread! (I don't know how to)


answered 08 Dec '17, 00:20

theoneyouwant's gravatar image

accept rate: 0%

There's an option close question near edit button, which will close your thread.

(08 Dec '17, 00:38) taran_14075★

You need some karma to close your thread afaik.

(08 Dec '17, 12:59) vijju123 ♦4★

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: 06 Dec '17, 21:49

question was seen: 170 times

last updated: 08 Dec '17, 12:59