[HackerRank][Python3] Climbing the Leaderboard
2018. 6. 1. 03:02 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem
My Solution :
#!/usr/bin/env python3
def climbingLeaderboard(scores, alice):
scores = sorted(set(scores), reverse=True)
ret = []
i, j = len(scores)-1, 0
while i > -1 and j < len(alice):
if alice[j] >= scores[i]: i -= 1
else:
ret.append(i+2)
j += 1
if i == -1: ret += [1]*(len(alice)-j)
return ret
scores_count = int(input())
scores = list(map(int, input().strip().split()))
alice_count = int(input())
alice = list(map(int, input().strip().split()))
result = climbingLeaderboard(scores, alice)
for rank in result:
print(rank)
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] Sam and substrings (0) | 2018.06.06 |
|---|---|
| [HackerRank][Python3] Marc's Cakewalk (0) | 2018.06.06 |
| [HackerRank][Python3] Minimum Loss (0) | 2018.06.05 |
| [HackerRank][Python3] Strong Password (0) | 2018.06.05 |
| [HackerRank][Python3] The Power Sum (1) | 2018.05.31 |
| [HackerRank][Python3] Construct the Array (0) | 2018.05.30 |
| [HackerRank][Python3] Minimum Absolute Difference in an Array (0) | 2018.05.29 |
| [HackerRank][Python3] Big Sorting (0) | 2018.05.29 |
최근에 달린 댓글 최근에 달린 댓글