You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
675 B
42 lines
675 B
#include <iostream>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
|
|
using namespace std;
|
|
|
|
typedef vector<unsigned> Input;
|
|
|
|
Input parse()
|
|
{
|
|
Input elves;
|
|
|
|
unsigned elf = 0;
|
|
for (string line; getline(cin, line);) {
|
|
if (line.empty()) {
|
|
elves.push_back(elf);
|
|
elf = 0;
|
|
continue;
|
|
}
|
|
elf += stoul(line);
|
|
}
|
|
|
|
sort(elves.begin(), elves.end(), greater<unsigned>());
|
|
return elves;
|
|
}
|
|
|
|
unsigned p1(Input &input)
|
|
{
|
|
return input[0];
|
|
}
|
|
|
|
unsigned p2(Input &input)
|
|
{
|
|
return input[0] + input[1] + input[2];
|
|
}
|
|
|
|
int main()
|
|
{
|
|
auto input = parse();
|
|
cout << p1(input) << endl;
|
|
cout << p2(input) << endl;
|
|
}
|
|
|