답안 #349892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349892 2021-01-18T15:55:27 Z Sho10 Maxcomp (info1cup18_maxcomp) C++17
100 / 100
135 ms 25196 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long 
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,a[1005][1005],pref[1005][1005],ans=0;
void change(ll n,ll m){
	for(ll i=1;i<=max(n,m);i++)
	{
		for(ll j=i+1;j<=max(n,m);j++)
		{
			swap(a[i][j],a[j][i]);
		}
	}
	for(ll i=1;i<=m;i++)
	{
		for(ll j=1;j<=n/2;j++)
		{
			swap(a[i][j],a[i][n-j+1]);
		}
	}
	return;
}
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=m;j++){
		cin>>a[i][j];
	}
}
for(ll i=0;i<=max(n,m);i++)
{
	pref[i][0]=LINF;
	pref[0][i]=LINF;
}
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=m;j++){
		pref[i][j]=min(pref[i-1][j],min(pref[i][j-1],a[i][j]-i-j));
		ans=max(ans,a[i][j]-i-j-min(pref[i-1][j],pref[i][j-1]));
	}
}
change(n,m);
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=m;j++){
		pref[i][j]=min(pref[i-1][j],min(pref[i][j-1],a[i][j]-i-j));
		ans=max(ans,a[i][j]-i-j-min(pref[i-1][j],pref[i][j-1]));
	}
}
change(m,n);
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=m;j++){
		pref[i][j]=min(pref[i-1][j],min(pref[i][j-1],a[i][j]-i-j));
		ans=max(ans,a[i][j]-i-j-min(pref[i-1][j],pref[i][j-1]));
	}
}
change(n,m);
for(ll i=1;i<=n;i++)
{
	for(ll j=1;j<=m;j++){
		pref[i][j]=min(pref[i-1][j],min(pref[i][j-1],a[i][j]-i-j));
		ans=max(ans,a[i][j]-i-j-min(pref[i-1][j],pref[i][j-1]));
	}
}
cout<<ans-1<<endl;
}
		

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 12268 KB Output is correct
2 Correct 12 ms 12300 KB Output is correct
3 Correct 12 ms 12268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 1 ms 748 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 748 KB Output is correct
14 Correct 1 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 12 ms 12268 KB Output is correct
10 Correct 12 ms 12300 KB Output is correct
11 Correct 12 ms 12268 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 1 ms 748 KB Output is correct
15 Correct 1 ms 748 KB Output is correct
16 Correct 1 ms 748 KB Output is correct
17 Correct 1 ms 748 KB Output is correct
18 Correct 134 ms 24684 KB Output is correct
19 Correct 131 ms 24684 KB Output is correct
20 Correct 125 ms 24300 KB Output is correct
21 Correct 130 ms 24684 KB Output is correct
22 Correct 131 ms 24684 KB Output is correct
23 Correct 130 ms 24684 KB Output is correct
24 Correct 135 ms 25196 KB Output is correct