Advertisement
a53

sotron1

a53
Aug 29th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("sotron1.in");
  4. ofstream fout("sotron1.out");
  5. int n, dp[243][243];
  6.  
  7. int main()
  8. {
  9. fin>>n;
  10. for(int i=1;i<=n;++i){
  11. for(int j=1;j<=n;++j){
  12. fin>>dp[i][j];
  13. }
  14. }
  15. for(int i=1;i<=n;++i){
  16. for(int j=n;j;--j){
  17. if((i+j)%2){
  18. if(dp[i][j+1]>0){
  19. dp[i][j]+=dp[i][j+1];
  20. }
  21. }
  22. else{
  23. if(dp[i-1][j]>0){
  24. dp[i][j]+=dp[i-1][j];
  25. }
  26. }
  27. }
  28. }
  29. int sol=0;
  30. for(int i=1;i<=n;++i){
  31. for(int j=1;j<=n;++j){
  32. sol=max(sol, dp[i][j]);
  33. }
  34. }
  35. fout<<sol;
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement