summaryrefslogtreecommitdiff
path: root/1a.c
diff options
context:
space:
mode:
Diffstat (limited to '1a.c')
-rw-r--r--1a.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/1a.c b/1a.c
new file mode 100644
index 0000000..fa93b39
--- /dev/null
+++ b/1a.c
@@ -0,0 +1,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;
+}
+