#include<cstdio>#include<cmath>#include<queue>#include<vector>#include<stack>#include<map>#include<string>#include<cstring>#include<algorithm>#include<iostream>using namespace std;typedef long long ll;const ll maxn = 100005;vector<int> t[maxn];int f[maxn][2];int n, m, q, x, y;int main(){while (scanf("%d%d%d", &n, &m, &q) == 3){for (int i = 1; i <= n; ++i) t[i].clear();while (m--){scanf("%d%d", &x, &y);t[x].push_back(y);}f[n + 1][0] = f[n + 1][1] = n + 1;for (int i = n; i; --i){f[i][0] = min(i, f[i + 1][0]);f[i][1] = min(i, f[i + 1][1]);for (int j = 0; j < t[i].size(); ++j){if (f[i][0] >= t[i][j]) { f[i][1] = f[i][0]; f[i][0] = t[i][j]; }else f[i][1] = min(f[i][1], t[i][j]);}}while (q--){scanf("%d", &x);printf("%dn", x - f[x][1]);}}return 0;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)