zoj 3888 Twelves Monkeys

zoj 3888 Twelves Monkeys,第1张

zoj 3888 Twelves Monkeys
#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;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4917926.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存