# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83577 | 2018-11-09T11:52:53 Z | ekrem | The Kingdom of JOIOI (JOI17_joioi) | C++ | 1391 ms | 24120 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(); cevir(); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Correct | 2 ms | 540 KB | Output is correct |
5 | Correct | 2 ms | 540 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 2 ms | 540 KB | Output is correct |
9 | Correct | 2 ms | 624 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Correct | 2 ms | 540 KB | Output is correct |
5 | Correct | 2 ms | 540 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 2 ms | 540 KB | Output is correct |
9 | Correct | 2 ms | 624 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 7 ms | 1548 KB | Output is correct |
17 | Correct | 11 ms | 1880 KB | Output is correct |
18 | Correct | 11 ms | 2152 KB | Output is correct |
19 | Correct | 14 ms | 2420 KB | Output is correct |
20 | Correct | 12 ms | 2564 KB | Output is correct |
21 | Correct | 15 ms | 3060 KB | Output is correct |
22 | Correct | 16 ms | 3448 KB | Output is correct |
23 | Correct | 17 ms | 3832 KB | Output is correct |
24 | Correct | 14 ms | 4092 KB | Output is correct |
25 | Correct | 20 ms | 4568 KB | Output is correct |
26 | Correct | 16 ms | 4952 KB | Output is correct |
27 | Correct | 16 ms | 5340 KB | Output is correct |
28 | Correct | 14 ms | 5856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 460 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Correct | 2 ms | 540 KB | Output is correct |
5 | Correct | 2 ms | 540 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 2 ms | 540 KB | Output is correct |
9 | Correct | 2 ms | 624 KB | Output is correct |
10 | Correct | 2 ms | 748 KB | Output is correct |
11 | Correct | 2 ms | 748 KB | Output is correct |
12 | Correct | 2 ms | 748 KB | Output is correct |
13 | Correct | 2 ms | 748 KB | Output is correct |
14 | Correct | 2 ms | 748 KB | Output is correct |
15 | Correct | 2 ms | 748 KB | Output is correct |
16 | Correct | 7 ms | 1548 KB | Output is correct |
17 | Correct | 11 ms | 1880 KB | Output is correct |
18 | Correct | 11 ms | 2152 KB | Output is correct |
19 | Correct | 14 ms | 2420 KB | Output is correct |
20 | Correct | 12 ms | 2564 KB | Output is correct |
21 | Correct | 15 ms | 3060 KB | Output is correct |
22 | Correct | 16 ms | 3448 KB | Output is correct |
23 | Correct | 17 ms | 3832 KB | Output is correct |
24 | Correct | 14 ms | 4092 KB | Output is correct |
25 | Correct | 20 ms | 4568 KB | Output is correct |
26 | Correct | 16 ms | 4952 KB | Output is correct |
27 | Correct | 16 ms | 5340 KB | Output is correct |
28 | Correct | 14 ms | 5856 KB | Output is correct |
29 | Correct | 709 ms | 23268 KB | Output is correct |
30 | Correct | 772 ms | 24120 KB | Output is correct |
31 | Correct | 911 ms | 24120 KB | Output is correct |
32 | Correct | 745 ms | 24120 KB | Output is correct |
33 | Correct | 674 ms | 24120 KB | Output is correct |
34 | Correct | 833 ms | 24120 KB | Output is correct |
35 | Correct | 1222 ms | 24120 KB | Output is correct |
36 | Correct | 1057 ms | 24120 KB | Output is correct |
37 | Correct | 1391 ms | 24120 KB | Output is correct |