0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 05:25:28 +00:00

P1130 红牌

R41016790
This commit is contained in:
Baoshuo Ren 2020-11-01 16:49:20 +08:00 committed by Baoshuo Ren
parent 1793e83e53
commit f5644225fc
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

25
problem/P1130/P1130.cpp Normal file
View 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;
}