TLE for Round #655 Div 2 Problem D (Omkar and circle), help

Revision en3, by Kaleab_Asfaw, 2020-07-18 23:36:39

Hey, In Round #655 problem D I am having TLE , 86974560

My idea (mostly similar to the editorial's but have some changes) is in the below image, Let n = 5, a = [1, 2, 3, 4, 5] and I have 2 steps.  One step 1 I start from the first element and move by 2, so from 1 --> 3 --> 5 --> 2 --> 4. I will create a array for this [1, 3, 5, 2, 4]. Then I will find the maximum sum of length (n + 1)/2 as maxx1.

On step 2 I will repeat the above from starting from the second element and move by 2, 2 --> 4 --> 1 --> 3 --> 5. [2, 4, 1, 3, 5]. Then find the maximum sum of length (n + 1)/2 as maxx2.

Return the max(maxx1, maxx2). That was all, I am sure it works (No Wrong Answer).

I guess the Time Complexity will be around O(n). Someone tell me if it is larger or know why the TLE occured?

Tags #tle, #help, #help error, #error

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Kaleab_Asfaw 2020-07-18 23:36:39 4 Tiny change: 'sion:86974490]\n\nMy i' -> 'sion:86974560]\n\nMy i'
en2 English Kaleab_Asfaw 2020-07-18 19:09:57 22 Tiny change: 'ditorial's) is in t' -> 'ditorial's but have some changes) is in t'
en1 English Kaleab_Asfaw 2020-07-18 19:09:07 907 Initial revision (published)