yoyoboyss

Untitled

Feb 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int NMAX = 102;
  5.  
  6. ifstream fin("sumtri.in");
  7. ofstream fout("sumtri.out");
  8.  
  9. int m[NMAX][NMAX], s[NMAX][NMAX];
  10. int N, Max;
  11.  
  12. int read(){
  13. fin >> N;
  14. for(int i=0; i<N; i++){
  15. for(int j=0; j<N; j++){
  16. if(j<i+1){
  17. fin >> m[i][j];
  18. s[i][j] = max(s[i-1][j], s[i-1][j-1]) + m[i][j];
  19. Max = max(s[i][j], Max);
  20. } else
  21. m[i][j] = -1;
  22. }
  23. }
  24. }
  25.  
  26. int main(){
  27.  
  28. read();
  29. fout << Max;
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment