PIKACHU - Help Pikachu
Our favourite Pokémon Pikachu was taught Arrays for the 1st time in his Computer Science class. On reaching home he was awed by the concept and a strange problem struck his mind. He wrote an array of numbers on a piece of paper.
For example say, 1 2 0 3 9 4 7 5 6 2 1. Now he observed that some elements like 5, 4, 3, 0, 2, 1 have at least one bigger element on their right. For example, 5 has one greater element 6; 4 has 5 and 6; 3 has 4, 5, 7, 6 and so on.
Since Pikachu is new to programming he needs your help.
Input
1st line contains a number T, the number of test cases.
For each test case the 1st line has an integer N (1 <= N <= 50) the size of the array.
The 2nd line consists of the array.
Output
An integer that corresponds to the required answer.
Example
Input: 1 5 5705 28145 23281 16827 9961 Output: 1
Explanation: 5705 is the only number that has at least one greater element to its right.
hide comments
nadstratosfer:
2018-07-19 23:54:31
With O(n^2) passing at 0.00s in Python, this should be moved to basics. IMHO a tutorial problem should accept suboptimal algo but at bad enough runtime to make people understand a better approach exists. |
Added by: | n.7n |
Date: | 2013-09-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Common problem |