summary refs log tree commit diff
path: root/22.1
diff options
context:
space:
mode:
Diffstat (limited to '22.1')
-rw-r--r--22.1/main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/22.1/main.cpp b/22.1/main.cpp
new file mode 100644
index 0000000..4a33aca
--- /dev/null
+++ b/22.1/main.cpp
@@ -0,0 +1,35 @@
+#include <algorithm>
+#include <iostream>
+#include <string>
+using namespace std;
+
+class Solution {
+	long best = -1;
+	long curtotal = 0;
+public:
+
+	void addItem(long cals) {
+		curtotal += cals;
+	}
+	void endElf() {
+		best = max(best, curtotal);
+		curtotal = 0;
+	}
+	long getAnswer() { return best; }
+};
+
+
+int
+main()
+{
+	Solution sol;
+	for (string line; getline(cin, line); ) {
+		if (line.length() > 0) {
+			sol.addItem(stol(line));
+		} else {
+			sol.endElf();
+		}
+	}
+	sol.endElf();
+	cout << sol.getAnswer() << endl;
+}