Submission #95346

# Submission time Handle Problem Language Result Execution time Memory
95346 2019-01-30T13:46:05 Z dalgerok Maxcomp (info1cup18_maxcomp) C++14
100 / 100
141 ms 28580 KB
#include<bits/stdc++.h>
using namespace std;



const int N = 1e3 + 5;



int n, m, a[N][N], dp1[N][N], dp2[N][N], dp3[N][N], dp4[N][N];



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            dp1[i][j] = max({dp1[i - 1][j], dp1[i][j - 1], a[i][j]}) - 1;
        }
        for(int j = m; j >= 1; j--){
            dp2[i][j] = max({dp2[i - 1][j], dp2[i][j + 1], a[i][j]}) - 1;
        }
    }
    for(int i = n; i >= 1; i--){
        for(int j = 1; j <= m; j++){
            dp3[i][j] = max({dp3[i + 1][j], dp3[i][j - 1], a[i][j]}) - 1;
        }
        for(int j = m; j >= 1; j--){
            dp4[i][j] = max({dp4[i + 1][j], dp4[i][j + 1], a[i][j]}) - 1;
        }
    }
    int ans = -1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            ans = max(ans, max({dp1[i][j], dp2[i][j], dp3[i][j], dp4[i][j]}) - a[i][j]);
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 3 ms 1400 KB Output is correct
12 Correct 3 ms 1400 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 3 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 1400 KB Output is correct
13 Correct 3 ms 1400 KB Output is correct
14 Correct 3 ms 1400 KB Output is correct
15 Correct 3 ms 1400 KB Output is correct
16 Correct 3 ms 1400 KB Output is correct
17 Correct 3 ms 1400 KB Output is correct
18 Correct 138 ms 28580 KB Output is correct
19 Correct 141 ms 28528 KB Output is correct
20 Correct 132 ms 28252 KB Output is correct
21 Correct 137 ms 28508 KB Output is correct
22 Correct 139 ms 28536 KB Output is correct
23 Correct 138 ms 28536 KB Output is correct
24 Correct 138 ms 28280 KB Output is correct