mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-11 16:31:58 +00:00
P1130 红牌
R41016790
This commit is contained in:
parent
1793e83e53
commit
f5644225fc
25
problem/P1130/P1130.cpp
Normal file
25
problem/P1130/P1130.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
long long n, m, a[2005][2005], f[2005][2005];
|
||||
cin >> n >> m;
|
||||
for(int i = 1 ; i <= m ; i++) {
|
||||
for(int j = 1 ; j <= n ; j++) {
|
||||
cin >> a[j][i];
|
||||
}
|
||||
}
|
||||
for(int i = 1 ; i <= n ; i++) {
|
||||
f[i-1][0] = f[i-1][m];
|
||||
for(int j = 1 ; j <= m ; j++) {
|
||||
f[i][j] = a[i][j] + min(f[i-1][j], f[i-1][j-1]);
|
||||
}
|
||||
}
|
||||
long long ans = f[n][1];
|
||||
for(int i = 2 ; i <= m ; i++) {
|
||||
ans = min(ans, f[n][i]);
|
||||
}
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user