01: Solve in C and Python
This commit is contained in:
commit
be7fa3b032
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
char l[8];
|
||||
int c, i, t, S, G = 0, E[256] = {0}, e = 0;
|
||||
|
||||
while (fgets(l, 8, stdin)) {
|
||||
E[e] += c = atoi(l);
|
||||
if (!c) e++;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++, t = 0) {
|
||||
for (c = 0; c <= e; c++) if (E[c] > E[t]) t = c;
|
||||
G += E[t];
|
||||
E[t] = 0;
|
||||
if (!i) S = G;
|
||||
}
|
||||
|
||||
printf("Silver: %d\nGold: %d\n", S, G);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
res = sorted(sum(map(int, l.split("\n"))) for l in sys.stdin.read().strip().split("\n\n"))[-3:]
|
||||
print(f"Silver: {res[-1]}\nGold: {sum(res)}")
|
Loading…
Reference in New Issue