ANUUND - Editorial . Plz tell me what is wrong with this soon. Thnx in advance

@invest123 You must take into account the separate test cases. you are printing for only one test case!

Thnx. OMG what a mistake :slight_smile: Dint notice that. I think i should use ideone to avoid these mistakes.

what is condition to test cases

He did not pass with this solution. I have updated the new solution.

Your solution is correct, but you are answering for a single test case only. You are not even reading number of test cases.

1 Like

I am not sure what the error was but the error was probably in map(int,s.split(" ")) , when I replaced it with [int(x) for x in s.split()] it worked .
Here is your corrected code .

1 Like

You are declaring the array in while (testcase --) loop, which is not correct. Number of test cases could be very huge, If you keep allocating so much memory for so many loops, you will get TLE. Ideally you should use vector or you should declare the array globally.

your sorting step is O(N 2 ). You need faster algorithms for sorting. Eg quicksort, mergesort etc. Btw you can use simply STL function sort.

A[i] >= A[i + 1] if i is odd.
A[i] <= A[i + 1] if i is even.

Hello guys! Iā€™m new to the platform.
How do I read the input using Pythong.

For a single integer you could use:

T = int(input())

And to get a set of whitespace-separated items into a list

items = input().split()

or if you want them as a list of integers:

values = list( map(int, input().split()) )
1 Like