#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
vector<int> l, r, machine_run_list;
vector<long long> last_run, dist;
signed main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, q, i, task, machine, past_days;
long long s, day;
cin >> n >> m >> q;
l = vector<int>(m + 1);
r = vector<int>(m + 1);
for (i = 1; i <= m; i++) {
cin >> l[i] >> r[i];
for (machine = l[i]; machine <= r[i]; machine++) {
machine_run_list.push_back(machine);
}
}
last_run = vector<long long>(n + 1, -1LL);
day = 1LL;
for (auto machine : machine_run_list) {
if (last_run[machine] == -1) {
// it has never been ran
last_run[machine] = day;
day++;
continue;
}
past_days = day - last_run[machine] - 1;
dist.push_back(past_days);
last_run[machine] = day;
day++;
}
sort(dist.begin(), dist.end());
for (i = 1; i <= q; i++) {
cin >> s;
auto it = lower_bound(dist.begin(), dist.end(), s);
while (it < dist.end() && !(*it >= s)) {
it++;
}
if (it >= dist.end()) {
cout << "0 ";
continue;
}
cout << dist.size() - (it - dist.begin()) << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |