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

×

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

Hi,

(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, 21:49

theoneyouwant's gravatar image

4★theoneyouwant
133
accept rate: 0%

closed 08 Dec, 02:33

vijju123's gravatar image

4★vijju123 ♦
11.3k1316

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, 22:06) theoneyouwant4★

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


Hi,

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)

link

answered 08 Dec, 00:20

theoneyouwant's gravatar image

4★theoneyouwant
133
accept rate: 0%

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

(08 Dec, 00:38) taran_14075★

You need some karma to close your thread afaik.

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

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×601
×457
×2

question asked: 06 Dec, 21:49

question was seen: 105 times

last updated: 08 Dec, 12:59