PROBLEM LINK:Author: Shiplu DIFFICULTY:Simple PREREQUISITES:Sort PROBLEM:Given a random sequence of N numbers, a[0..N1], sort them in order and report the difference between the sum of numbers in odd positions and the sum of numbers in even position. EXPLANATION:If a quick sort is directly applied, the time complexity is O(N logN). But the range of numbers is small, within 1,000,000. Therefore, we can use the counting sort, that is,
Go through the count array again, we can get the order. With this algorithm, we can solve this problem in O(X) time, where X is the range of all numbers. AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution can be found here.
This question is marked "community wiki".
asked 18 Mar '14, 20:33

I'd like to ask the community here if questions like
are cheating or not? I understand that asking a questions is part of learning process, but here (and I'm not telling this is the first case), it's related to ongoing contest and even such question is kind of hint I think... answered 18 Mar '14, 21:14
2
@betlista I wouldn't consider them as cheating. Sorting and searching are commonly known algorithms and these questions are mostly asked by beginners who want to learn. If you look at my answer and other answers they are general answers and not specific to any question. This info is easily available on others sites also. However asking question specific details is certainly unwelcome.
(19 Mar '14, 18:31)

In Python, for same logic I am getting TLE :(
Any idea why is this not working? answered 20 Mar '14, 20:18

Can anyone explain me why we must use the bool array as in this example.?
answered 14 Apr '14, 01:36

Guys, I am getting SIGSEGV, please help. Since the strength can't be greater than 1000000, I used a boolean array s[1000000] of this size, true means the strength is taken by a person, if two persons are there with same strength then they would be in different teams and cancel out the difference of strengths, so for every strength temp that comes during iteration, I have used
} answered 27 Dec '14, 16:59

can someone explain this portion ?
Can anyone explain me why we must use the bool array as in this example.?