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.
|
|
|
#define OLC_PGE_APPLICATION
|
|
|
|
#include "pixelGameEngine.h"
|
|
|
|
#include "olcutils.h"
|
|
|
|
|
|
|
|
using namespace olc;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::vector<int>elf_data;
|
|
|
|
std::ifstream file("input");
|
|
|
|
int largest=0;
|
|
|
|
while (file.good()){
|
|
|
|
std::string val;
|
|
|
|
std::getline(file,val);
|
|
|
|
int calorie_count=0;
|
|
|
|
while (val.length()>1&&file.good()) {
|
|
|
|
calorie_count+=std::atoi(val.c_str());
|
|
|
|
std::getline(file,val);
|
|
|
|
}
|
|
|
|
elf_data.push_back(calorie_count);
|
|
|
|
if (largest<calorie_count) {
|
|
|
|
largest=calorie_count;
|
|
|
|
}
|
|
|
|
std::cout<<"elf data: "<<calorie_count<<std::endl;
|
|
|
|
}
|
|
|
|
std::sort(elf_data.begin(),elf_data.end());
|
|
|
|
int sum=0;
|
|
|
|
for (int i=0;i<3;i++) {
|
|
|
|
int data=elf_data[elf_data.size()-i-1];
|
|
|
|
std::cout<<"Largest "<<i<<": "<<data<<std::endl;
|
|
|
|
sum+=data;
|
|
|
|
}
|
|
|
|
std::cout<<"Sum of 3: "<<sum<<std::endl;
|
|
|
|
return 0;
|
|
|
|
}
|