https://www.hackerrank.com/challenges/bon-appetit/problem
HackerRank - Bon Appétit
#!/bin/python3import mathimport osimport randomimport reimport sysdef bonAppetit(bill, k, b): payAnna = (sum(bill) - bill[k]) / 2 output = '' if(payAnna == b): output = 'Bon Appetit' else: output = str(int(b - payAnna)) print(output)if __name__ == '__main__': nk = input().rstrip().split() n = int(nk[0]) k = int(nk[1]) bill = list(map(int, input().rstrip().split())) b = int(input().strip()) bonAppetit(bill, k, b)
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
| HackerRank - Drawing Book (0) | 2019.01.29 |
|---|---|
| HackerRank - Sock Merchant (0) | 2019.01.28 |
| HackerRank - Day of the Programmer (0) | 2019.01.25 |
| HackerRank - Migratory Birds (0) | 2019.01.24 |
| HackerRank - Divisible Sum Pairs (0) | 2019.01.23 |