202203-2出行计划
题解:
#include<iostream>
#include<cstring>
#define N 200005
using namespace std;
int main() {
int n, m, k;
cin >> n >> m >> k;
int* res = new int[N];
memset(res, 0, N * sizeof(int));
for(int i=0; i<n; i++) {
int t, c;
cin >> t >> c;
int b = max(0, t - c - k + 1);
int a = max(0, t - k + 1);
res[b]++;
res[a]--;
}
for(int i=1; i<N; i++) {
res[i] += res[i-1];
}
for(int i=0; i<m; i++) {
int q;
cin >> q;
cout << res[q] << endl;
}
return 0;
}