Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save inspirit941/fb1be5b3bb3001a1192c32351c648261 to your computer and use it in GitHub Desktop.

Select an option

Save inspirit941/fb1be5b3bb3001a1192c32351c648261 to your computer and use it in GitHub Desktop.
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the climbingLeaderboard function below.
def climbingLeaderboard(scores, alice):
queue = sorted(set(scores), reverse = True)
idx = len(queue) - 1
answer = []
for alice_score in alice:
while queue[idx] <= alice_score and idx >= 0:
idx -= 1
if idx < 0 :
answer.append(1)
continue
# print(queue , queue[idx], idx, alice_score)
answer.append(idx + 2)
return answer
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
scores_count = int(input())
scores = list(map(int, input().rstrip().split()))
alice_count = int(input())
alice = list(map(int, input().rstrip().split()))
result = climbingLeaderboard(scores, alice)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment