为什么会全wa啊!!!help

P1776 宝物筛选

@[Exile_Code](/user/819682) 有没有可能 ``` for(int j=m;j>=v[i];j--) ``` 要改成 ``` for(int j=m;j>=w[i];j--) ```
by hash_peas @ 2023-07-26 09:37:01


@[Exile_Code](/user/819682) 实测改过的代码已AC code ``` #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; #include <vector> #include <set> #include <map> #include <unordered_map> #include <cstdio> #include <cstring> #include <queue> #include <cstdlib> #include <algorithm> #include <list> #include <string> #include <cmath> #include <bitset> const int MAXN = 1e5+ 8; int main() { int n, m; cin >> n >> m; int f[MAXN], v[MAXN]; int w[MAXN]; int cnt = 0; memset(f, 0, sizeof(f)); for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; int k = 1; while (k <= c) { cnt++; v[cnt] = a * k; w[cnt] = b * k; c -= k; k *= 2; } if (c > 0) { cnt++; v[cnt] = a * c; w[cnt] = b * c; } } for (int i = 1; i <= cnt; i++) for (int j = m;j>=w[i]; --j) f[j] = max(f[j], f[j -w[i]] +v[i] ); cout << f[m] << endl; return 0; } ```
by hash_peas @ 2023-07-26 09:37:43


没必要定义MAXN,白白占空间
by AlphaStar @ 2023-07-26 09:44:34


话说开那么多头文件干嘛(
by hash_peas @ 2023-07-26 09:46:03


建议循环加大括号,否则太难看
by AlphaStar @ 2023-07-26 09:46:10


@[xxx666xxx](/user/774876) 而且不用.h,难看(doge)
by AlphaStar @ 2023-07-26 09:47:47


@[xxx666xxx](/user/774876) vs用不了万能头啊
by Exile_Code @ 2023-07-26 10:54:09


@[Exile_Code](/user/819682) 可是你这程序开个```#include<iostream>```就好了
by hash_peas @ 2023-07-26 11:01:12


@[AlphaStar](/user/1037925) 什么小周老师(uid 1000048,看他主页最后一个链接,里面全假的
by Zpril_20211017 @ 2023-07-26 18:00:31


|