AcWing 4455. 出行计划
原题链接
简单
作者:
王欢祥
,
2024-12-03 21:27:07
,
所有人可见
,
阅读 1
#include <iostream>
#include <cstring>
using namespace std;
const int N = 1e5 + 7;
int n, m, k;
int s[2 * N];
int main() {
cin >> n >> m >> k;
memset(s, 0, sizeof s);
for (int i = 1; i <= n; i++) {
int t, c;
cin >> t >> c;
int x = t - c + 1 - k;
int y = t - k;
int begin = max(x, 0);
int end = max(y, 0);
s[begin]++;
s[end + 1]--;
}
for (int i = 1; i <= 2 * N; i++)
s[i] += s[i - 1];
for (int i = 0; i < m; i++) {
int q;
cin >> q;
cout << s[q] << endl;
}
return 0;
}