1 条题解
-
0
裸差分吧,
虽然数据水暴力随便锤对于每个,标记从到间需要的桶数量加上,用差分来搞,一个数组,表示时刻比时刻需要的桶数多,那么对于每头牛,就要加,就减,最后求前缀和再取个就完事了。
#include <bits/stdc++.h> using namespace std; int n, s, t, b, p[1010]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d%d%d", &s, &t, &b); p[s - 1] += b, p[t] -= b; } int ans = 0, h = 0;//h即前缀和 for (int i = 0; i <= 1001; ++i) { ans = max(ans, h); h += p[i]; } cout << ans << endl; return 0; }
- 1
信息
- ID
- 6776
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 26
- 已通过
- 17
- 上传者