44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#include <cstdint>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct Range {
|
|
uint64_t lowerInclusiveBound = 0;
|
|
uint64_t upperInclusiveBound = 0;
|
|
};
|
|
|
|
int main() {
|
|
std::fstream input("input");
|
|
std::string currentLine = "";
|
|
std::getline(input, currentLine, '\n');
|
|
std::vector<Range> ranges{};
|
|
uint16_t positionOfHypen = 0;
|
|
|
|
// Range and values are seperated by an empty \n
|
|
while (currentLine != "") {
|
|
positionOfHypen = currentLine.find('-');
|
|
// Sorry its ugly but it just gets the numbers
|
|
ranges.push_back({std::stoull(currentLine.substr(0, positionOfHypen)),
|
|
std::stoull(currentLine.substr(positionOfHypen + 1))});
|
|
|
|
std::getline(input, currentLine, '\n');
|
|
}
|
|
|
|
uint64_t currentProduceID = 0, freshProduceCount = 0;
|
|
while (std::getline(input, currentLine, '\n')) {
|
|
currentProduceID = std::stoull(currentLine);
|
|
for (Range currentRange : ranges) {
|
|
if (currentRange.lowerInclusiveBound <= currentProduceID &&
|
|
currentProduceID <= currentRange.upperInclusiveBound) {
|
|
freshProduceCount++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
std::cout << freshProduceCount << std::endl;
|
|
return 0;
|
|
}
|