[HackerRank][Python3] Luck Balance
2018. 7. 15. 22:59 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/luck-balance/problem
My Solution :
#!/usr/bin/env python3 def luckBalance(k, contests): T0, T1 = [], [] for L, T in contests: if T == 1: T1.append(L) else: T0.append(L) T1.sort(reverse=True) return sum(T1[:k]) - sum(T1[k:]) + sum(T0) n, k = map(int, input().split()) contests = [] for _ in range(n): contests.append(list(map(int, input().rstrip().split()))) result = luckBalance(k, contests) print(result)
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Hash Tables: Ice Cream Parlor (0) | 2018.07.16 |
---|---|
[HackerRank][Python3] Triple sum (0) | 2018.07.16 |
[HackerRank][Python3] Max Min (0) | 2018.07.16 |
[HackerRank][Python3] Greedy Florist (0) | 2018.07.16 |
[HackerRank][Python3] Common Child (0) | 2018.07.15 |
[HackerRank][Python3] Sherlock and the Valid String (0) | 2018.07.15 |
[HackerRank][Python3] Strings: Making Anagrams (0) | 2018.07.15 |
[HackerRank][Python3] Count Triplets (0) | 2018.07.13 |
최근에 달린 댓글 최근에 달린 댓글