Submission #1022433

# Submission time Handle Problem Language Result Execution time Memory
1022433 2024-07-13T13:39:59 Z MrAndria Maxcomp (info1cup18_maxcomp) C++14
100 / 100
264 ms 21332 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first;
#define ss second
#define pb push_back
//#define int long long
int n,m,a[1005][1005],mx,dp[1005][1005],b[1005][1005];
int replace(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            b[j][n-i+1]=a[i][j];
        }
    }
    swap(n,m);
    mx=-INT_MAX;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            a[i][j]=b[i][j];
        }
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=1;j<=m;j++){
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            dp[i][j]=-INT_MAX;
        }
    }
    // cout<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),-a[i][j]+i+j);
            // cout<<dp[i][j]<<" ";
            mx=max(mx,a[i][j]-i-j+dp[i][j]-1);
        }
        // cout<<endl;
    }
    // cout<<mx<<endl;
    return mx;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    cout<<max(max(replace(),replace()),max(replace(),replace()))<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 12376 KB Output is correct
2 Correct 5 ms 12124 KB Output is correct
3 Correct 5 ms 12120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 1112 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 5 ms 12376 KB Output is correct
10 Correct 5 ms 12124 KB Output is correct
11 Correct 5 ms 12120 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 856 KB Output is correct
18 Correct 240 ms 20696 KB Output is correct
19 Correct 233 ms 20564 KB Output is correct
20 Correct 230 ms 20376 KB Output is correct
21 Correct 238 ms 20564 KB Output is correct
22 Correct 264 ms 20560 KB Output is correct
23 Correct 240 ms 20656 KB Output is correct
24 Correct 247 ms 21332 KB Output is correct