7 solutions
-
0
#include <bits/stdc++.h> using namespace std; int ma[1010][1010]; int sum[1010][1010]; int main() { int r; cin>>r; for(int i=1;i<=r;i++) { for(int j=1;j<=i;j++) cin>>ma[i][j]; } for(int i=1;i<=r;i++) { for(int j=1;j<=i;j++) { sum[i][j]=ma[i][j]+max(sum[i-1][j],sum[i-1][j-1]); } } cout<<*max_element(sum[r]+1,sum[r]+1+r); }
Information
- ID
- 87
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 238
- Accepted
- 95
- Uploaded By