We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
0 parents commit 83c5af4Copy full SHA for 83c5af4
1.caloriecounting.py
@@ -0,0 +1,28 @@
1
+from heapq import heappop, heappush
2
+
3
+lst = []
4
+counter = 1
5
+total = 0
6
7
+while True:
8
+ try:
9
+ line = input()
10
11
+ if not line:
12
+ heappush(lst, (-total, counter))
13
+ total = 0
14
15
+ elif line == 'STOP':
16
+ for _ in range(3):
17
+ highest = heappop(lst)
18
+ print(-highest[0])
19
20
+ else:
21
+ total += int(line)
22
23
+ except EOFError:
24
+ break
25
26
27
28
0 commit comments