-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.py
47 lines (32 loc) · 964 Bytes
/
solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/python
import os
import math
def climbingLeaderboard(scores, alice):
scores.append(0)
scores_index = 0
alice_index = len(alice)-1
rank = 0
ranks = []
last_score = object()
while alice_index >= 0:
a_score = scores[scores_index]
alice_score = alice[alice_index]
if a_score != last_score:
rank += 1
if a_score <= alice_score:
ranks.append(rank)
alice_index -= 1
else:
scores_index += 1
last_score = a_score
return reversed(ranks)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
scores_count = int(raw_input())
scores = map(int, raw_input().rstrip().split())
alice_count = int(raw_input())
alice = map(int, raw_input().rstrip().split())
result = climbingLeaderboard(scores, alice)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()