blob: fa93b3911a3d5c97a8bdcd3e9a33907b12bfdc8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <stdio.h>
#include <stdlib.h>
int
main()
{
char buf[BUFSIZ];
long cal = 0, maxcal = 0, elf = 0, maxelf = 0;
while (fgets(buf, sizeof(buf), stdin)) {
char * pbuf = buf;
long n;
if ((n = strtol(buf, &pbuf, 10)) == 0 && pbuf == buf) {
if (cal > maxcal) {
maxcal = cal;
maxelf = elf;
}
cal = 0;
++elf;
}
else {
cal += n;
}
}
if (cal > maxcal) {
maxcal = cal;
maxelf = elf;
}
printf("maxcal: %ld (elf: %ld)\n", maxcal, maxelf);
return 0;
}
|