답안 #221488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221488 2020-04-10T09:51:59 Z kshitij_sodani The Kingdom of JOIOI (JOI17_joioi) C++17
100 / 100
1587 ms 70648 KB
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>

#include <functional>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <numeric>
#include <random>
#include <ratio>
#include <sstream>
#include <utility>

#include <bitset>
#include <deque>
#include <queue>
#include <map>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <string>
#include <set>

using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;
llo n,m;
llo it[2001][2001];
llo mi=1000000001;
llo ma=0;
llo check(){
	llo low=0;
	llo high=ma-1;
	while(low<high){
		llo mid=(low+high)/2;
		llo st=1;
		llo ll=0;
		for(llo i=0;i<n;i++){
			for(llo j=0;j<m;j++){
				if(it[i][j]<ma-mid){
					ll=max(ll,j+1);
				}
			}
			for(llo j=0;j<ll;j++){
				if(it[i][j]>mi+mid){
					st=0;
				}
			}
		}
		if(st){
			high=mid;
		}
		else{
			low=mid+1;
		}
	}
	return low;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	for(llo i=0;i<n;i++){
		for(llo j=0;j<m;j++){
			cin>>it[i][j];
			ma=max(ma,it[i][j]);
			mi=min(mi,it[i][j]);
		}
	}
	llo ans=check();
	for(llo i=0;i<n;i++){
		for(llo j=0;j<m/2;j++){
			swap(it[i][j],it[i][m-j-1]);
		}
	}
	ans=min(ans,check());
	for(llo i=0;i<n/2;i++){
		for(llo j=0;j<m;j++){
			swap(it[i][j],it[n-i-1][j]);
		}
	}
	ans=min(ans,check());
	for(llo i=0;i<n;i++){
		for(llo j=0;j<m/2;j++){
			swap(it[i][j],it[i][m-j-1]);
		}
	}
	ans=min(ans,check());
	cout<<ans<<endl;



	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 9 ms 1536 KB Output is correct
17 Correct 16 ms 1792 KB Output is correct
18 Correct 15 ms 1792 KB Output is correct
19 Correct 16 ms 1792 KB Output is correct
20 Correct 15 ms 1512 KB Output is correct
21 Correct 19 ms 1920 KB Output is correct
22 Correct 20 ms 1792 KB Output is correct
23 Correct 20 ms 1920 KB Output is correct
24 Correct 16 ms 1664 KB Output is correct
25 Correct 21 ms 1920 KB Output is correct
26 Correct 19 ms 1792 KB Output is correct
27 Correct 19 ms 1920 KB Output is correct
28 Correct 20 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 9 ms 1536 KB Output is correct
17 Correct 16 ms 1792 KB Output is correct
18 Correct 15 ms 1792 KB Output is correct
19 Correct 16 ms 1792 KB Output is correct
20 Correct 15 ms 1512 KB Output is correct
21 Correct 19 ms 1920 KB Output is correct
22 Correct 20 ms 1792 KB Output is correct
23 Correct 20 ms 1920 KB Output is correct
24 Correct 16 ms 1664 KB Output is correct
25 Correct 21 ms 1920 KB Output is correct
26 Correct 19 ms 1792 KB Output is correct
27 Correct 19 ms 1920 KB Output is correct
28 Correct 20 ms 1920 KB Output is correct
29 Correct 995 ms 52264 KB Output is correct
30 Correct 978 ms 53368 KB Output is correct
31 Correct 1086 ms 55032 KB Output is correct
32 Correct 991 ms 54904 KB Output is correct
33 Correct 827 ms 47992 KB Output is correct
34 Correct 1069 ms 55032 KB Output is correct
35 Correct 1445 ms 70488 KB Output is correct
36 Correct 1244 ms 65400 KB Output is correct
37 Correct 1587 ms 70648 KB Output is correct