# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45531 | IvanC | Maxcomp (info1cup18_maxcomp) | C++17 | 206 ms | 56176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
const int INF = 1e9 + 1e4;
int N,M,matriz[MAXN][MAXN],linear[MAXN],melhor;
int main(){
scanf("%d %d",&N,&M);
melhor = 0;
for(int i = 1;i<=N;i++){
for(int j = 1;j<=M;j++){
scanf("%d",&matriz[i][j]);
}
}
for(int i = 1;i<=N;i++) linear[i] = INF;
for(int j = 1;j<=M;j++){
int menor = INF;
for(int i = 1;i<=N;i++){
linear[i] = min(linear[i] + 1, matriz[i][j] );
menor = min(menor+1,linear[i]);
melhor = max(melhor, matriz[i][j] - menor );
}
menor = INF;
for(int i = N;i>=1;i--){
menor = min(menor+1,linear[i]);
melhor = max(melhor, matriz[i][j] - menor );
}
}
for(int i = 1;i<=N;i++) linear[i] = INF;
for(int j = M;j>=1;j--){
int menor = INF;
for(int i = 1;i<=N;i++){
linear[i] = min(linear[i] + 1, matriz[i][j] );
menor = min(menor+1,linear[i]);
melhor = max(melhor, matriz[i][j] - menor );
}
menor = INF;
for(int i = N;i>=1;i--){
menor = min(menor+1,linear[i]);
melhor = max(melhor, matriz[i][j] - menor );
}
}
printf("%d\n",melhor - 1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |