2 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=1e3+11; int main() { int m[N][N],dp[N][N],i,j,n,max1=0; cin>>n; for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ cin>>m[i][j]; } } for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ dp[i][j]=max(dp[i-1][j],dp[i-1][j-1])+m[i][j]; if(dp[i][j]>max1){ max1=dp[i][j]; } } } cout<<max1; return 0; }
Information
- ID
- 556
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- 4
- Tags
- # Submissions
- 45
- Accepted
- 22
- Uploaded By