Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("sotron1.in");
- ofstream fout("sotron1.out");
- int n, dp[243][243];
- int main()
- {
- fin>>n;
- for(int i=1;i<=n;++i){
- for(int j=1;j<=n;++j){
- fin>>dp[i][j];
- }
- }
- for(int i=1;i<=n;++i){
- for(int j=n;j;--j){
- if((i+j)%2){
- if(dp[i][j+1]>0){
- dp[i][j]+=dp[i][j+1];
- }
- }
- else{
- if(dp[i-1][j]>0){
- dp[i][j]+=dp[i-1][j];
- }
- }
- }
- }
- int sol=0;
- for(int i=1;i<=n;++i){
- for(int j=1;j<=n;++j){
- sol=max(sol, dp[i][j]);
- }
- }
- fout<<sol;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement