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

×

TLE on Hussain Set from May Cook-Off 2017

Hi guys, I've been working optimizing the solution of this problem for a long time; and, I've no idea now why it's getting TLE. The complexity is (NlogN + N * 63). Here it is : https://www.codechef.com/viewsolution/13787521

Algorithm is simple. I'll divide all the elements into 63 stacks as per their log value. Stacks will be processed starting from the one with greatest log value. And, for each element x in the stack, I'll store x/2 into a queue. While processing the next stack (with lower log value), I'll also consider the queue created from the previous step.

asked 26 May '17, 10:20

ptntialunrlsd's gravatar image

5★ptntialunrlsd
285
accept rate: 0%

edited 26 May '17, 10:21


My solution is somewhat similar to your approach, see if it can help :)

https://www.codechef.com/viewsolution/13788391

link

answered 26 May '17, 12:41

sahil070197's gravatar image

5★sahil070197
171
accept rate: 20%

Thanks so much. Mine got accepted after initializing the deque with the initial capacity. Seems array copying was wasting execution time.

(26 May '17, 17:23) ptntialunrlsd5★
toggle preview
Preview

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:

×729
×173
×81
×46
×11

question asked: 26 May '17, 10:20

question was seen: 418 times

last updated: 26 May '17, 17:23