Smaller Scores
A group of people(
P) are playing an online game. Their scores are stored in the order of their entry time in S. Each integer S[i] corresponds to the score of the person Pi.For each person
The first line contains a single integer
The output should contain
Given
S = 13 12 11Score of
P1 is 13. Score of P2 is 12. Score of P3 is 11.The number of people who played after
P1 and scored less than 13 is 2(12, 11). The number of people who played after P2 and scored less than 12 is 1(11). The number of people who played after P3 and scored less than 11 is 0.
The output is
2 1 0.
Sample Input 1
3
13 12 11
Sample Output 1
2 1 0
def scores(L:list, N:int):
s = [0 for i in range(N)]
for i in range(N-1):
for j in range(i+1,N):
if L[i] > L[j]:
s[i] += 1
print(*s)
while True:
try:
N = int(input())
if N == 0:
break
L = list(map(int,input().split()))
if len(L) != N:
raise ValueError
except ValueError:
print('incorect input')
continue
scores(L,N)
Comments
Leave a comment