45 lines
695 B
C++
45 lines
695 B
C++
#include <fstream>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
struct range
|
|
{
|
|
long int min;
|
|
long int max;
|
|
};
|
|
|
|
int main()
|
|
{
|
|
std::ifstream file("input.txt");
|
|
|
|
std::vector<range> fresh_ranges;
|
|
|
|
std::string line;
|
|
while (getline(file, line)) {
|
|
if (line == "") break;
|
|
|
|
range range;
|
|
sscanf(line.c_str(), "%ld-%ld", &range.min, &range.max);
|
|
|
|
fresh_ranges.push_back(range);
|
|
}
|
|
|
|
int fresh_amount = 0;
|
|
|
|
while (getline(file, line)) {
|
|
long int id = std::stol(line);
|
|
bool is_fresh = false;
|
|
|
|
for (range range : fresh_ranges) {
|
|
if (id >= range.min && id <= range.max) {
|
|
is_fresh = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (is_fresh) fresh_amount++;
|
|
}
|
|
|
|
std::cout << fresh_amount << std::endl;
|
|
}
|