Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f("sumtri.in");
- ofstream g("sumtri.out");
- int x,d[101][101];
- int n;
- int main()
- {
- f>>n;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=i;j++){
- f>>x;
- d[i][j]=max(d[i-1][j-1] + x,d[i-1][j] + x);
- ///cout<<d[i][j]<<'\t';
- }
- ///cout<<'\n';
- }
- int maxx=d[n][1];
- for(int i=1;i<=n;i++){
- maxx=max(maxx,d[n][i]);
- }
- g<<maxx;
- return 0;
- }
Add Comment
Please, Sign In to add comment