2 条题解
-
4
01背包
#include <bits/stdc++.h> using namespace std; int v , n , w[35] , f[20005]; int main() { cin >> v >> n; for (int i = 1 ; i <= n ; i++) cin >> w[i]; for (int i = 1 ; i <= n ; i++) { for (int j = v ; j >= w[i] ; j--) { f[j] = max(f[j] , f[j - w[i]] + w[i]); } } cout << v - f[v]; return 0; }
-
hetao1411188 @ 2022-12-8 9:06:25
关于5分钟内在同一道题不同的人发了2条题解这件事
-
hetao2909413 @ 2022-12-8 9:28:52
(沉默) (惊讶) (欣喜若狂)
-
hetao1411188 @ 2022-12-8 9:32:48
hh
-
hetao1156052 @ 2022-12-31 9:45:40
-
hetao1411188 @ 2022-12-31 9:54:29
-
-
3hetao2909413 LV 10 @ 2022-12-8 8:50:41
#include <iostream> using namespace std; int m, n, f[20000], w[40]; int main() { cin >> m >> n; for (int i = 1; i <= n; i += 1) { cin >> w[i]; } for (int i = 1; i <= n; i += 1) { for (int j = m; j >= w[i]; j -= 1) { if (f[j] < f[j - w[i]] + w[i]) { f[j] = f[j - w[i]] + w[i]; } } } cout<< m - f[m] << endl; return 0; }//已AC
-
hetao2909413 @ 2022-12-8 9:30:48
关于5分钟内在同一道题不同的人发了2条题解这件事 (额······无话可说 )(给两个LV 10的大佬点个👍 呗)
-
hetao1411188 @ 2022-12-8 9:33:20
我点👍 了
-
hetao1411188 @ 2022-12-8 9:35:32
你看评测记录吗
-
hetao2909413 @ 2022-12-8 9:37:29
我肯定看了
-
hetao1411188 @ 2022-12-8 9:46:18
你每天几点刷题呀,我每天早上和下午刷
-
hetao1411188 @ 2022-12-8 9:47:50
-
hetao2909413 @ 2022-12-8 9:55:11
-
hetao1411188 @ 2022-12-8 9:58:58
-
hetao1411188 @ 2022-12-8 10:20:34
-
hetao2909413 @ 2022-12-8 10:22:30
对了,你试试点进这个网站看看(黑客入侵) https://pranx.com/hacker/
-
hetao1411188 @ 2022-12-8 10:23:35
-
hetao1411188 @ 2022-12-8 10:27:47
-
hetao1156052 @ 2022-12-31 9:44:33
六
-
hetao1156052 @ 2022-12-31 9:49:37
都是五年级啊,是哪个学校的?
-
hetao1156052 @ 2022-12-31 9:50:11
现在都放假了
-
hetao1411188 @ 2022-12-31 9:54:00
-
hetao1156052 @ 2022-12-31 9:57:45
-
hetao1156052 @ 2022-12-31 10:49:26
-
hetao1411188 @ 2023-1-4 14:43:30
-
hetao1156052 @ 2023-1-5 23:25:12
-
hetao1411188 @ 2023-1-6 10:16:51
-
hetao1156052 @ 2023-1-19 19:26:00
-
- 1