답안 #83575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83575 2018-11-09T11:50:44 Z ekrem The Kingdom of JOIOI (JOI17_joioi) C++
0 / 100
6 ms 636 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son)/2)
#define inf 1000000007
#define N 2005
using namespace std;

int n, m, ans = inf, mx, mn, a[N][N];

void cevir();
void cevir2();

bool dene(int frk){
	if(mx - mn <= frk)
		return 1;
	int bas = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++)
			if(mx - a[i][j] > frk)
				bas = max(bas, j + 1);

		for(int j = 1; j <= m; j++)
			if(a[i][j] - mn > frk)
				if(j < bas)
					return 0;
	}
	return 1;
}

void coz(){
	int bas = 0;
	int son = inf;
	while(bas < son){
		if(dene(orta))
			son = orta;
		else
			bas = orta + 1;
	}
	// cout << orta << endl;
	ans = min(ans, orta);
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	mn = inf;
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++){
			scanf("%d",&a[i][j]);
			mx = max(mx, a[i][j]);
			mn = min(mn, a[i][j]);
		}
	coz();
	cevir();
	coz();
	cevir2();
	coz();
	cevir2();
	coz();
	printf("%d\n", ans);
	return 0;
}

















void cevir(){
	for(int j = 1; j <= m; j++)
		for(int i = 1; i <= n/2; i++)
			swap(a[i][j], a[n - i + 1][j]);
}

void cevir2(){
	for(int i = 1; i <= n; i++)
		reverse(a[i] + 1, a[i] + m + 1);
}

Compilation message

joioi.cpp: In function 'int main()':
joioi.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~
joioi.cpp:53:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 6 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Incorrect 2 ms 636 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 6 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Incorrect 2 ms 636 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 6 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Incorrect 2 ms 636 KB Output isn't correct
12 Halted 0 ms 0 KB -