| 比赛 |
2026.1.8 |
评测结果 |
AAEEEEEEEEEEEEEEEEEE |
| 题目名称 |
区间价值 |
最终得分 |
10 |
| 用户昵称 |
梦那边的美好BP |
运行时间 |
2.516 s |
| 代码语言 |
C++ |
内存使用 |
3.40 MiB |
| 提交时间 |
2026-01-08 21:05:13 |
显示代码纯文本
#include <algorithm>
#include <iostream>
using namespace std;
struct node {
int l, r, w;
} a[1000];
bool cmp(node x, node y) { return x.l < y.l; }
int n;
int ans = 0;
void dfs(int l, int mx, int now) {
if (l == n + 1) {
ans = max(ans, now);
return;
}
dfs(l + 1, mx, now);
if (a[l].l > mx) {
dfs(l + 1, max(mx, a[l].r), now + a[l].w);
}
}
int main() {
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].l >> a[i].r >> a[i].w;
}
sort(a + 1, a + 1 + n, cmp);
dfs(1, 0, 0);
cout << ans;
return 0;
}