mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 15:16:28 +00:00
parent
713d5e6156
commit
eecfe2dbac
30
S2OJ/9/9.cpp
Normal file
30
S2OJ/9/9.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 20005;
|
||||
|
||||
int s, n, a[N], f[N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> s >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = s; j >= a[i]; j--) {
|
||||
f[j] = std::max(f[j], f[j - a[i]] + a[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << s - f[s] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/9/data/ex_land1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/ex_land1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/ex_land1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/ex_land1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/land5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/land5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/9/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/9/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user