mid-kid
3 years ago
commit
9e62c56eca
4 changed files with 2032 additions and 0 deletions
@ -0,0 +1 @@ |
|||||
|
CXXFLAGS := -std=c++17 -O2 -Wall -Wextra |
@ -0,0 +1,29 @@ |
|||||
|
#include <iostream> |
||||
|
#include <fstream> |
||||
|
#include <vector> |
||||
|
using namespace std; |
||||
|
|
||||
|
int main(int argc, char *argv[]) { |
||||
|
if (argc <= 1) return 1; |
||||
|
ifstream input(argv[1]); |
||||
|
|
||||
|
vector<unsigned> numbers; |
||||
|
unsigned num; |
||||
|
while (input >> num) { |
||||
|
numbers.push_back(num); |
||||
|
} |
||||
|
|
||||
|
unsigned part1 = 0; |
||||
|
for (size_t i = 1; i < numbers.size(); i++) { |
||||
|
if (numbers[i] > numbers[i-1]) part1++; |
||||
|
} |
||||
|
cout << part1 << endl; |
||||
|
|
||||
|
unsigned part2 = 0; |
||||
|
for (size_t i = 4; i < numbers.size(); i++) { |
||||
|
unsigned win1 = numbers[i-1] + numbers[i-2] + numbers[i-3]; |
||||
|
unsigned win2 = numbers[i] + numbers[i-1] + numbers[i-2]; |
||||
|
if (win2 > win1) part2++; |
||||
|
} |
||||
|
cout << part2 << endl; |
||||
|
} |
File diff suppressed because it is too large
@ -0,0 +1,2 @@ |
|||||
|
1301 |
||||
|
1346 |
Loading…
Reference in new issue