Created
March 6, 2020 07:32
-
-
Save inspirit941/fb1be5b3bb3001a1192c32351c648261 to your computer and use it in GitHub Desktop.
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
| #!/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