# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51528 | 2018-06-18T07:12:23 Z | MoesashiMinamoto | The Kingdom of JOIOI (JOI17_joioi) | C++14 | 2 ms | 520 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int h[4], w[4]; int a[4][2003][2003]; int mi; void preproc() { for(int t = 1; t < 4; t++) { h[t] = w[t-1]; w[t] = h[t-1]; for (int i = 1; i <= h[t-1]; i++) { for (int j = 1; j <= w[t-1]; j++) { a[t][j][h[t-1]-i+1] = a[t-1][i][j]; } } } } bool chec(int k) { for (int t = 0; t < 4; t++) { int lim, nexlim = w[t]; int ma = -INT_MAX, mii = INT_MAX; for (int i = 1; i <= h[t]; i++) { lim = nexlim; for (int j = 1; j <= lim; j++) { if (a[t][i][j] <= mi + k) { continue; } else { nexlim = j-1; break; } } for (int j = lim+1; j <= w[t]; j++) { mii = min(mii, a[t][i][j]); ma = max(ma, a[t][i][j]); } } if (ma - mii <= k) return true; } return false; } signed main() { scanf("%lld%lld", &h[0], &w[0]); mi = INT_MAX; for (int i = 1; i <= h[0]; i++) { for (int j = 1; j <= w[0]; j++) { scanf("%lld", &a[0][i][j]); mi = min(mi, a[0][i][j]); } } preproc(); /*for (int t = 0; t < 4; t++) { for (int i = 1; i <= h[t]; i++) { for (int j = 1; j <= w[t]; j++) { printf ("%d ", a[t][i][j]); } printf("\n"); } printf("\n"); }*/ int res = 0; for (int j = 33; j >= 0; j--) { if (res + (1ll << j) <= 1000000000) { int cur = res + (1ll << j); if (!chec(cur)) { res = cur; } } } printf("%lld", res+1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Incorrect | 2 ms | 520 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Incorrect | 2 ms | 520 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Incorrect | 2 ms | 520 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |