Created
September 14, 2019 02:43
-
-
Save atul-chaudhary/2911cd787ca459099c7f23690bceb7a9 to your computer and use it in GitHub Desktop.
traveloka : programming Question
This file contains hidden or 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
1 | |
10 | |
A 10 | |
A 15 | |
A 20 | |
I 10 | |
A 22 | |
D 5 | |
A 27 | |
P 3 | |
P 2 | |
P 5 | |
#here is the program | |
t=int(input()) | |
for _ in range(t): | |
q=int(input()) | |
lst_re=[] | |
lst_re1=[] | |
l=len(lst_re) | |
for _ in range(q): | |
lst=input().split() | |
print(lst) | |
if(lst[0]=='A'): | |
lst_re.append(int(lst[1])) | |
elif(lst[0]=='I'): | |
for i in range(len(lst_re)): | |
lst_re[i]+=int(lst[1]) | |
elif(lst[0]=='D'): | |
for i in range(len(lst_re)): | |
lst_re[i]-=int(lst[1]) | |
elif(lst[0]=='P'): | |
lst_sor=sorted(lst_re,reverse=True) | |
lst_re1.append(lst_sor[int(lst[1])-1]) | |
for j in range(len(lst_re1)): | |
print(lst_re1[j]) | |
lst_re.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment