Submission #407139

# Submission time Handle Problem Language Result Execution time Memory
407139 2021-05-18T14:47:20 Z victoriad Maxcomp (info1cup18_maxcomp) C++14
100 / 100
137 ms 16936 KB
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>   
#include <array>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>   
#include <array>
#include <iomanip>
#include <fstream>
#include <cstdlib>
 
using namespace std;
 
 
 int main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin>>n>>m;
   int A[n][m];
   int memo[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>A[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			memo[i][j]=A[i][j];
			if(i>0){
				memo[i][j]=max(memo[i][j],memo[i-1][j]-1);
			}
			if(j>0){
				memo[i][j]=max(memo[i][j],memo[i][j-1]-1);
			}
		}
	}
	for(int i=n-1;i>=0;i--){
		for(int j=m-1;j>=0;j--){
			if(i<n-1){
				memo[i][j]=max(memo[i][j],memo[i+1][j]-1);
			}
			if(j<m-1){
				memo[i][j]=max(memo[i][j],memo[i][j+1]-1);
			}
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			ans=max(ans,memo[i][j]-A[i][j]-1);
		}
	}
   cout<<ans;
    return 0;
 }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 228 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 228 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 228 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 134 ms 16568 KB Output is correct
19 Correct 134 ms 16568 KB Output is correct
20 Correct 124 ms 15912 KB Output is correct
21 Correct 132 ms 16568 KB Output is correct
22 Correct 137 ms 16580 KB Output is correct
23 Correct 136 ms 16560 KB Output is correct
24 Correct 129 ms 16936 KB Output is correct