#include #include #include #include using namespace std; class Solution { array best = {0}; long curtotal = 0; public: void addItem(long cals) { curtotal += cals; } void endElf() { if (best[0] < curtotal) { best[0] = curtotal; // i wonder if the compiler is smart enough to skip the second if // would honestly be pretty terrifying if (best[0] > best[1]) swap(best[0], best[1]); if (best[1] > best[2]) swap(best[1], best[2]); } curtotal = 0; } long getPartOne() { return best[2]; } long getPartTwo() { return best[0] + best[1] + best[2]; } }; 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.getPartOne() << endl; cout << sol.getPartTwo() << endl; }