You are not logged in. Please login at 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 :

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

accept rate: 0%

edited 26 May '17, 10:21

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


answered 26 May '17, 12:41

sahil070197's gravatar image

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

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: 26 May '17, 10:20

question was seen: 418 times

last updated: 26 May '17, 17:23