P9977[USACO23DEC]BovineAcrobaticsS
https://www.luogu.com.cn/problem/P9977
https://www.luogu.com.cn/article/ijti2qdg
最后一段的理解,个人认为不妥,应该根据代码来看:
#include <stdio.h>
#include <algorithm>
struct node {
int a, b;
} c[200010];
bool cmp(node a, node b) {
return a.b < b.b;
}
int ans[200010], id = 1;
long long res;
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= n; i++)
scanf("%d%d", &c[i].b, &c[i].a);
std::sort(c + 1, c + 1 + n, cmp);
for (int i = 1; i <= n; i++) {
while (id < i && c[i].b - c[id].b >= k)
m += ans[id++];
ans[i] = m < c[i].a ? m : c[i].a; //系统自带的min有点慢
m -= ans[i], res += ans[i];
}
printf("%lld", res);
return 0;
}
首先它是往塔底放的,因为
本文作者:wscqwq
本文链接:https://www.cnblogs.com/wscqwq/p/18420859
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2023-09-19 引水入城
2023-09-19 保卫王国
2023-09-19 开车旅行