# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
317092 | daniel920712 | Maxcomp (info1cup18_maxcomp) | C++14 | 210 ms | 8440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int all[1005][1005];
int small1[1005][1005];
int main()
{
int N,M,ans=-2e9,i,j,k,l;
scanf("%d %d",&N,&M);
for(i=1;i<=N;i++) for(j=1;j<=M;j++) scanf("%d",&all[i][j]);
for(i=0;i<=N+1;i++) for(j=0;j<=M+1;j++) small1[i][j]=2e9;
for(i=1;i<=N;i++)
{
for(j=1;j<=M;j++)
{
small1[i][j]=min(small1[i][j],small1[i-1][j]);
small1[i][j]=min(small1[i][j],small1[i][j-1]);
small1[i][j]=min(small1[i][j],all[i][j]-i-j);
ans=max(ans,all[i][j]-i-j-small1[i][j]);
}
}
for(i=0;i<=N+1;i++) for(j=0;j<=M+1;j++) small1[i][j]=2e9;
for(i=N;i>=1;i--)
{
for(j=1;j<=M;j++)
{
small1[i][j]=min(small1[i][j],small1[i+1][j]);
small1[i][j]=min(small1[i][j],small1[i][j-1]);
small1[i][j]=min(small1[i][j],all[i][j]+i-j);
ans=max(ans,all[i][j]+i-j-small1[i][j]);
}
}
for(i=0;i<=N+1;i++) for(j=0;j<=M+1;j++) small1[i][j]=2e9;
for(i=1;i<=N;i++)
{
for(j=M;j>=1;j--)
{
small1[i][j]=min(small1[i][j],small1[i-1][j]);
small1[i][j]=min(small1[i][j],small1[i][j+1]);
small1[i][j]=min(small1[i][j],all[i][j]-i+j);
ans=max(ans,all[i][j]-i+j-small1[i][j]);
}
}
for(i=0;i<=N+1;i++) for(j=0;j<=M+1;j++) small1[i][j]=2e9;
for(i=N;i>=1;i--)
{
for(j=M;j>=1;j--)
{
small1[i][j]=min(small1[i][j],small1[i+1][j]);
small1[i][j]=min(small1[i][j],small1[i][j+1]);
small1[i][j]=min(small1[i][j],all[i][j]+i+j);
ans=max(ans,all[i][j]+i+j-small1[i][j]);
}
}
printf("%d\n",ans-1);
return 0;
}
컴파일 시 표준 에러 (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... |