28 lines
592 B
C++
28 lines
592 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
const int MAX_T=105,MAX_N=105,MAX_M=1e4+5;
|
|
int T,N,M;
|
|
int p[MAX_T][MAX_N];
|
|
int dp[MAX_M];
|
|
#define MEM(a,s,n){for(int i=1;i<=s;i++)a[i]=n;}
|
|
|
|
int main(){
|
|
cin>>T>>N>>M;
|
|
for(int i=1;i<=T;i++){
|
|
for(int j=1;j<=N;j++){
|
|
cin>>p[i][j];
|
|
}
|
|
}
|
|
for(int i=1;i<T;i++){
|
|
MEM(dp,MAX_M-1,0);
|
|
for(int j=1;j<=N;j++){
|
|
for(int k=p[i][j];k<=M;k++){
|
|
dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]-p[i][j]);
|
|
}
|
|
}
|
|
M+=dp[M];
|
|
}
|
|
cout<<M<<endl;
|
|
} |