# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
20964 | 2017-03-23T05:57:36 Z | kdh9949 | The Kingdom of JOIOI (JOI17_joioi) | C++14 | 3649 ms | 33584 KB |
#include <bits/stdc++.h> using namespace std; int n, m, mn = 1e9, a[2010][2010], b[2010][2010]; void rot(){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ b[j][n + 1 - i] = a[i][j]; } } swap(n, m); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ a[i][j] = b[i][j]; } } } int can(int k){ for(int dum = 0; dum < 4; dum++){ int lst = m, omx = 0, omn = 1e9; for(int i = 1; i <= n; i++){ for(int j = 1; j <= lst; j++){ if(a[i][j] > mn + k){ lst = j - 1; break; } } for(int j = lst + 1; j <= m; j++){ omx = max(omx, a[i][j]); omn = min(omn, a[i][j]); } } if(omx - omn <= k) return 1; if(dum < 3) rot(); } return 0; } int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ scanf("%d", a[i] + j); mn = min(mn, a[i][j]); } } int s = 0, e = 1e9; while(s <= e){ int mid = (s + e) / 2; if(can(mid)) e = mid - 1; else s = mid + 1; } printf("%d\n", s); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33584 KB | Output is correct |
2 | Correct | 0 ms | 33584 KB | Output is correct |
3 | Correct | 0 ms | 33584 KB | Output is correct |
4 | Correct | 0 ms | 33584 KB | Output is correct |
5 | Correct | 0 ms | 33584 KB | Output is correct |
6 | Correct | 0 ms | 33584 KB | Output is correct |
7 | Correct | 0 ms | 33584 KB | Output is correct |
8 | Correct | 0 ms | 33584 KB | Output is correct |
9 | Correct | 0 ms | 33584 KB | Output is correct |
10 | Correct | 0 ms | 33584 KB | Output is correct |
11 | Correct | 0 ms | 33584 KB | Output is correct |
12 | Correct | 0 ms | 33584 KB | Output is correct |
13 | Correct | 0 ms | 33584 KB | Output is correct |
14 | Correct | 0 ms | 33584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33584 KB | Output is correct |
2 | Correct | 0 ms | 33584 KB | Output is correct |
3 | Correct | 0 ms | 33584 KB | Output is correct |
4 | Correct | 0 ms | 33584 KB | Output is correct |
5 | Correct | 0 ms | 33584 KB | Output is correct |
6 | Correct | 0 ms | 33584 KB | Output is correct |
7 | Correct | 0 ms | 33584 KB | Output is correct |
8 | Correct | 0 ms | 33584 KB | Output is correct |
9 | Correct | 0 ms | 33584 KB | Output is correct |
10 | Correct | 0 ms | 33584 KB | Output is correct |
11 | Correct | 0 ms | 33584 KB | Output is correct |
12 | Correct | 0 ms | 33584 KB | Output is correct |
13 | Correct | 0 ms | 33584 KB | Output is correct |
14 | Correct | 0 ms | 33584 KB | Output is correct |
15 | Correct | 0 ms | 33584 KB | Output is correct |
16 | Correct | 6 ms | 33584 KB | Output is correct |
17 | Correct | 13 ms | 33584 KB | Output is correct |
18 | Correct | 16 ms | 33584 KB | Output is correct |
19 | Correct | 9 ms | 33584 KB | Output is correct |
20 | Correct | 13 ms | 33584 KB | Output is correct |
21 | Correct | 19 ms | 33584 KB | Output is correct |
22 | Correct | 23 ms | 33584 KB | Output is correct |
23 | Correct | 19 ms | 33584 KB | Output is correct |
24 | Correct | 23 ms | 33584 KB | Output is correct |
25 | Correct | 16 ms | 33584 KB | Output is correct |
26 | Correct | 16 ms | 33584 KB | Output is correct |
27 | Correct | 16 ms | 33584 KB | Output is correct |
28 | Correct | 19 ms | 33584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33584 KB | Output is correct |
2 | Correct | 0 ms | 33584 KB | Output is correct |
3 | Correct | 0 ms | 33584 KB | Output is correct |
4 | Correct | 0 ms | 33584 KB | Output is correct |
5 | Correct | 0 ms | 33584 KB | Output is correct |
6 | Correct | 0 ms | 33584 KB | Output is correct |
7 | Correct | 0 ms | 33584 KB | Output is correct |
8 | Correct | 0 ms | 33584 KB | Output is correct |
9 | Correct | 0 ms | 33584 KB | Output is correct |
10 | Correct | 0 ms | 33584 KB | Output is correct |
11 | Correct | 0 ms | 33584 KB | Output is correct |
12 | Correct | 0 ms | 33584 KB | Output is correct |
13 | Correct | 0 ms | 33584 KB | Output is correct |
14 | Correct | 0 ms | 33584 KB | Output is correct |
15 | Correct | 0 ms | 33584 KB | Output is correct |
16 | Correct | 6 ms | 33584 KB | Output is correct |
17 | Correct | 13 ms | 33584 KB | Output is correct |
18 | Correct | 16 ms | 33584 KB | Output is correct |
19 | Correct | 9 ms | 33584 KB | Output is correct |
20 | Correct | 13 ms | 33584 KB | Output is correct |
21 | Correct | 19 ms | 33584 KB | Output is correct |
22 | Correct | 23 ms | 33584 KB | Output is correct |
23 | Correct | 19 ms | 33584 KB | Output is correct |
24 | Correct | 23 ms | 33584 KB | Output is correct |
25 | Correct | 16 ms | 33584 KB | Output is correct |
26 | Correct | 16 ms | 33584 KB | Output is correct |
27 | Correct | 16 ms | 33584 KB | Output is correct |
28 | Correct | 19 ms | 33584 KB | Output is correct |
29 | Correct | 2349 ms | 33584 KB | Output is correct |
30 | Correct | 2116 ms | 33584 KB | Output is correct |
31 | Correct | 2113 ms | 33584 KB | Output is correct |
32 | Correct | 1909 ms | 33584 KB | Output is correct |
33 | Correct | 2056 ms | 33584 KB | Output is correct |
34 | Correct | 2113 ms | 33584 KB | Output is correct |
35 | Correct | 3649 ms | 33584 KB | Output is correct |
36 | Correct | 2593 ms | 33584 KB | Output is correct |
37 | Correct | 3489 ms | 33584 KB | Output is correct |