| 比赛 |
2026.1.8 |
评测结果 |
WWWWWWTTTWWWWWWWWWWW |
| 题目名称 |
最大价值 |
最终得分 |
0 |
| 用户昵称 |
LikableP |
运行时间 |
3.852 s |
| 代码语言 |
C++ |
内存使用 |
6.97 MiB |
| 提交时间 |
2026-01-08 20:59:03 |
显示代码纯文本
#include <cstdio>
#include <vector>
#include <algorithm>
const int MAXN = 1e5 + 10;
int n, m;
struct Seq {
int l, r;
int w;
};
std::vector<Seq> level[MAXN];
int levelchoose[MAXN];
long long ans;
bool CanChoose(Seq x, Seq y) {
return x.l > y.r;
}
void dfs(int step, long long now) {
if (step > m) {
ans = std::max(ans, now);
return ;
}
for (size_t i = 0; i < level[step].size(); ++i) {
if (CanChoose(level[step][i], level[step - 1][levelchoose[step - 1]])) {
levelchoose[step] = i;
dfs(step + 1, now + level[step][i].w);
}
}
}
int main() {
#ifdef LOCAL
freopen("!input.in", "r", stdin);
freopen("!output.out", "w", stdout);
#else
freopen("power.in", "r", stdin);
freopen("power.out", "w", stdout);
#endif
level[0].push_back({0, 0, 0});
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) {
int belong, w, l, r;
scanf("%d %d %d %d", &belong, &w, &l, &r);
level[belong].push_back({l, r, w});
}
dfs(1, 0);
printf("%lld\n", ans);
return 0;
}