mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
parent
7f9094e5ec
commit
f1fed88c8a
51
S2OJ/45/45.cpp
Normal file
51
S2OJ/45/45.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 105,
|
||||
M = 17;
|
||||
|
||||
int n, m, fee[N], cost[N][M], f[N][1 << M], ans = 0x3f3f3f3f;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> fee[i];
|
||||
|
||||
for (int j = 0; j < m; j++) {
|
||||
cin >> cost[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
memset(f[0], 0x3f, sizeof(f[0]));
|
||||
f[0][0] = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
f[i][j] = f[i - 1][j] + fee[i];
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
for (int k = 0; k < m; k++) {
|
||||
if (j & (1 << k)) continue;
|
||||
|
||||
f[i][j | (1 << k)] = std::min(f[i][j | (1 << k)], f[i][j] + cost[i][k]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1 << m; j++) {
|
||||
f[i][j] = std::min(f[i][j], f[i - 1][j]);
|
||||
}
|
||||
}
|
||||
|
||||
cout << f[n][(1 << m) - 1] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/45/data/cen1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen14.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen15.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen16.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/cen9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/cen9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/ex_cen2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/ex_cen2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/45/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/45/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user