# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
200579 | 2020-02-07T12:47:54 Z | quocnguyen1012 | 구경하기 (JOI13_watching) | C++14 | 181 ms | 16124 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 2005; int f[maxn][maxn]; int a[maxn], N; int P, Q; bool check(int len) { const int inf = 1e9; fill_n(&f[0][0], maxn * maxn, inf); f[0][0] = 0; int l = 1, r = 1; for (int i = 1; i <= N; ++i){ while (l <= N && a[l] <= a[i] - len) ++l; while (r <= N && a[r] <= a[i] - 2 * len) ++r; for (int j = 0; j <= min(i, P); ++j){ if (j > 0) f[i][j] = f[l - 1][j - 1]; f[i][j] = min(f[i][j], f[r - 1][j] + 1); } } return f[N][min(N, P)] <= Q; } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> P >> Q; for (int i = 1; i <= N; ++i){ cin >> a[i]; } sort(a + 1, a + 1 + N); int l = 1, r = 1e9, mid; while (l <= r){ mid = (l + r) / 2; if (!check(mid)) l = mid + 1; else r = mid - 1; } cout << l; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 94 ms | 15992 KB | Output is correct |
2 | Correct | 90 ms | 16124 KB | Output is correct |
3 | Incorrect | 98 ms | 16120 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 16120 KB | Output is correct |
2 | Correct | 95 ms | 16120 KB | Output is correct |
3 | Incorrect | 181 ms | 16124 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |