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


Help in Codeforces Power Array TLE!

I have used mo's algorithm to solve this question... But still I'm getting TLE!!! And I can't understand why I'm getting TLE for different test case numbers by doing minor changes. (The overall time complexity should remain same even after doing these changes!)

This code gives TLE on test case 41, This one gives TLE in test case 43 (Removed sorting step from previous code and instead stored results in a different array)

asked 16 Feb '18, 17:38

dushyant7917's gravatar image

accept rate: 0%


You may find this previously asked question helpful: link

(16 Feb '18, 18:11) meooow ♦6★

Thanks the link really helped! But can you tell me @meooow why such small modifications like converting ll to int and using inline functions have so much effect on running time!

(17 Feb '18, 10:21) dushyant79175★

Yup, thanks to @meooow for cool info. Btw, I know the reason for inline function. By using inline function, the compiler inserts the body of the function wherever you call the function and thus no stack push/pop operations for function calls and stuff. This saves time.

Well the trick used in sorting is quite fascinating though :)

(18 Feb '18, 01:28) dishant_185★

Yes @dishant_18 is right about inline functions. Only one correction, the inline keyword is only a suggestion to the compiler, and the compiler may decide not to replace the calls with the function body.

(18 Feb '18, 14:13) meooow ♦6★
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: 16 Feb '18, 17:38

question was seen: 242 times

last updated: 18 Feb '18, 14:22