[HackerRank][Python3] Equal
2018. 5. 16. 01:03 |
프로그래밍/HackerRank
그다지 어려운 문제가 아닌데, 아무리 봐도 내가 틀리지 않은 것 같은데 계속 틀렸다고 나와서 몇 시간을 낭비했다... 알고보니 문제가 중간에 변경되었으나 Testcase는 변경되기 전 기준과 변경 후 기준이 섞여 있는 상태...
2018년 5월 16일 현재 기준으로, 문제는 1, 3, 5개의 초콜릿을 배분할 수 있지만, 초창기에는 1, 2, 5개의 초콜릿이었던 것 같다.
Problem :
https://www.hackerrank.com/challenges/equal/problem
My Solution :
#!/usr/bin/env python3
DP = [0, 1, 2, 1, 2]
def equal(a):
m = min(a)
c = 0
for i in range(len(a)):
b = a[i] - m
if b == 0: continue
c += b//5 + DP[b%5]
return c
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().strip().split()))
print(equal(a))
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] Big Sorting (0) | 2018.05.29 |
|---|---|
| [HackerRank][Python3] CamelCase (0) | 2018.05.27 |
| [HackerRank][Python3] Journey to the Moon (0) | 2018.05.25 |
| [HackerRank][Python3] Hackerland Radio Transmitters (0) | 2018.05.23 |
| [HackerRank][Python3] Sherlock and Cost (0) | 2018.05.21 |
| [HackerRank][Python3] Maximum Subarray Sum (0) | 2018.05.18 |
| [HackerRank][Python3] The Coin Change Problem (0) | 2018.05.15 |
| [HackerRank][Python3] Super Reduced String (2) | 2018.05.11 |
최근에 달린 댓글 최근에 달린 댓글