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
686 B
42 lines
686 B
2 years ago
|
#include <iostream>
|
||
|
#include <vector>
|
||
|
#include <algorithm>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
vector<unsigned> parse()
|
||
|
{
|
||
|
vector<unsigned> elves;
|
||
|
|
||
|
string line;
|
||
|
unsigned elf = 0;
|
||
|
while (getline(cin, line)) {
|
||
|
if (line.empty()) {
|
||
|
elves.push_back(elf);
|
||
|
elf = 0;
|
||
|
continue;
|
||
|
}
|
||
|
elf += stoul(line);
|
||
|
}
|
||
|
|
||
|
sort(elves.begin(), elves.end(), greater<int>());
|
||
|
return elves;
|
||
|
}
|
||
|
|
||
|
unsigned p1(vector<unsigned> &input)
|
||
|
{
|
||
|
return input[0];
|
||
|
}
|
||
|
|
||
|
unsigned p2(vector<unsigned> &input)
|
||
|
{
|
||
|
return input[0] + input[1] + input[2];
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
auto input = parse();
|
||
|
cout << p1(input) << endl;
|
||
|
cout << p2(input) << endl;
|
||
|
}
|