blob: 4a33aca2a32f5bcf6c9ef3f30ebeba38f1aac90c (
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
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;
}
|