Created
September 29, 2019 06:37
-
-
Save praveeng1618/20193c41f8fa13d5fdffde4be1281390 to your computer and use it in GitHub Desktop.
maximum power
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
power=[] | |
klist=[] | |
def pokemon(q): | |
for j in range(q): | |
z, y = input().split() | |
y=int(y) | |
if z=='a': | |
power.append(y) | |
elif z=='i': | |
for s in range(len(power)): | |
power[s]=power[s]+y | |
elif z=='d': | |
for s in range(len(power)): | |
power[s]=power[s]-y | |
else: | |
klist.append(y) | |
power.sort() | |
power.reverse() | |
for s in klist: | |
print(power[s-1]) | |
klist.clear() | |
power.clear() | |
t=int(input()) | |
for i in range(t): | |
q=int(input()) | |
pokemon(q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maximum power
Mike is a Pokemon trainer and always roams arcuri the Pokemon world. The pokemon world contains two major stops
Stop 1: Decrement in the power of all the pokemon, trainers have at that point of time by some X.
Stop 2: increment in the power of all the pokemon, trainers have at that point of time by some x
Help Mike determine the Kth largest power of the pokemon that he has with him
INPUT FORMAT :
First line. T denoting the number of test cases
Each test case contains Q queries
Output format
Print the answer for all type P queries in a new line