Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int N=205;
- int rubbish[N][N],dp[N][N];
- void init(int n,int m)
- {
- for(int i=0;i<=n;i++){
- dp[0][i]=0;
- }
- for(int i=0;i<=m;i++){
- dp[i][0]=0;
- }
- }
- int main(){
- int n,m;
- while(scanf("%d%d",&n,&m)!=EOF){
- init(n,m);
- memset(dp,0,sizeof(dp));
- for(int i=1;i<=n;i++){
- for(int j=1;i<=m;j++){
- cin>>rubbish[i][j];
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=m;j++){
- dp[i][j]=max(dp[i-1][j],dp[i][j-1])+rubbish[i][j];
- }
- }
- cout<<dp[n][m]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement