[HackerRank][Python3] Equal Stacks
                2018. 9. 2. 21:38 |
                
                    프로그래밍/HackerRank
                
            
            
            
        Problem :
https://www.hackerrank.com/challenges/equal-stacks/problem
My Solution :
#!/usr/bin/env python3
def equal_stacks(h1, h2, h3):
    sum_h1 = sum(h1)
    sum_h2 = sum(h2)
    sum_h3 = sum(h3)
    while not (sum_h1 == sum_h2 == sum_h3):
        max_h = max(sum_h1, sum_h2, sum_h3)
        if sum_h1 == max_h:
            sum_h1 -= h1.pop()
        if sum_h2 == max_h:
            sum_h2 -= h2.pop()
        if sum_h3 == max_h:
            sum_h3 -= h3.pop()
    return sum_h1
_ = input()
h1 = list(map(int, input().rstrip().split()[::-1]))
h2 = list(map(int, input().rstrip().split()[::-1]))
h3 = list(map(int, input().rstrip().split()[::-1]))
result = equal_stacks(h1, h2, h3)
print(result)
Comment :
모난 돌이 정 맞는다. 모든 실린더의 키가 같아질 때까지 매회 키 큰 실린더를 깎아내린다.
'프로그래밍 > HackerRank' 카테고리의 다른 글
| [HackerRank][Python3] HackerRank in a String! (0) | 2018.09.03 | 
|---|---|
| [HackerRank][Python3] Truck Tour (0) | 2018.09.03 | 
| [HackerRank][Python3] Waiter (0) | 2018.09.03 | 
| [HackerRank][Python3] Simple Text Editor (0) | 2018.09.02 | 
| [HackerRank][Python3] Maximum Element (0) | 2018.09.02 | 
| [HackerRank][Python3] Matrix Layer Rotation (2) | 2018.08.08 | 
| [HackerRank][Python3] Dijkstra: Shortest Reach 2 (0) | 2018.08.07 | 
| [HackerRank][Python3] Tries: Contacts (0) | 2018.08.05 | 
최근에 달린 댓글 최근에 달린 댓글