1157LITTLE SHOP OF FLOWERS
最近老是没有ACCEPT,看到这道题目就想让自己找回些自信
#include "iostream" #define INF -1000000 using namespace std; int max(int a ,int b){return a>b?a:b;} int main(){ int m,n,i,j,map[120][120],dp[120][120],k; while(cin>>m>>n){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ cin>>map[i][j]; } } int temp=INF; for(i=0;i<=n;i++)dp[0][i]=0; for(i=1;i<=m;i++){ for(j=1;j<=n-m+i;j++){ dp[i][j]=INF; for(k=i-1;k<j;k++){ if(dp[i][j]<dp[i-1][k]+map[i][j]){ dp[i][j]=dp[i-1][k]+map[i][j]; if(i==m)temp=max(temp,dp[i][j]); } } } } cout<<temp<<endl; } }