1
0
Fork 0
Advent2021/Day 6/Marcus/cpp/part1.cpp

34 lines
658 B
C++

#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> fish(300);
for(int i = 0; i < 300; i++) cin >> fish[i];
for(int i = 0; i < 80; i++)
{
int new_fish_count = 0;
for(int j = 0; j < fish.size(); j++)
{
if (--fish[j] < 0)
{
fish[j] = 6;
new_fish_count++;
}
}
vector<int> new_fish(new_fish_count, 8);
fish.insert(fish.end(), new_fish.begin(), new_fish.end());
}
cout << fish.size() << endl;
return 0;
}