×

# TLE on Hussain Set from May Cook-Off 2017

 0 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 28●5 accept rate: 0%

 0 My solution is somewhat similar to your approach, see if it can help :) https://www.codechef.com/viewsolution/13788391 answered 26 May '17, 12:41 17●1 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)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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