版本比较
决策延后和随机映射
正文
增加 10 行删除 3 行
123431 行未改动36373839404142434445464748495051525354555657585960616263646566676869104 行未改动全部展开## 写在前面这个决策延后是个盗版。不是 DP 那个。31 行未改动这道题目是合并延后的入门题,是弱化版。```cppusing namespace std;const int N = 1e6 + 5;struct node {int v, w, k;} a[N];bool cmp(node x, node y) {return x.k < y.k;}int main() {int n, m;cin >> n >> m;for(int i = 1; i <= n; i++) {cin >> a[i].w >> a[i].v >> a[i].k;}sort(a + 1, a + n + 1, cmp);int ans = 0, anss = 0;for(int i = 1; i <= n; i++) {if(m + a[i].k < a[i].w) {anss += a[i].v;}else {ans = anss = anss + a[i].v;}}cout << ans;}```### 例二、AT_nikkei2019_qual_e Weights on Vertices and Edges104 行未改动全部展开1234567831 行未改动40414243444546474849505152535455565758596061626364656667686970717273747576104 行未改动全部展开**2026/6/12:例题一修改了代码。****2026/6/15:又修改了代码。**## 写在前面这个决策延后是个盗版。不是 DP 那个。31 行未改动这道题目是合并延后的入门题,是弱化版。```cpp#include <bits/stdc++.h>using namespace std;const int N = 1e6 + 5;struct node {int v, w, k;} a[N];bool cmp(node x, node y) {return x.w < y.w;}int main() {int n, m;cin >> n >> m;for(int i = 1; i <= n; i++) {cin >> a[i].w >> a[i].v >> a[i].k;}sort(a + 1, a + n + 1, cmp);int ans = 0, anss = 0, mx = 0;for(int i = 1; i <= n; i++) {if(m + mx < a[i].w) {anss += a[i].v;}else {ans = anss = anss + a[i].v;}mx = max(mx, a[i].k);}cout << ans;}```### 例二、AT_nikkei2019_qual_e Weights on Vertices and Edges104 行未改动全部展开