| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 59140 | RezwanArefin01 | 구경하기 (JOI13_watching) | C++17 | 729 ms | 16876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 2010;
int n, p, q, a[N], dp[N][N], w;
int np[N], nq[N];
int f(int i, int t) {
if(t > p) return 1e9;
if(i == n) return 0;
int &ret = dp[i][t];
if(~ret) return ret;
return ret = min(f(np[i], t + 1), 1 + f(nq[i], t));
}
bool check(int w) {
int j = 0, k = 0;
for(int i = 0; i < n; i++) {
while(j < n && a[i] + w > a[j]) j++;
while(k < n && a[i] + w + w > a[k]) k++;
np[i] = j; nq[i] = k;
}
memset(dp, -1, sizeof dp);
return f(0, 0) <= q;
}
int main(int argc, char const *argv[]) {
scanf("%d %d %d", &n, &p, &q);
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
p = min(p, n);
sort(a, a + n);
int lo = 1, hi = 1e9, ans = -1;
while(lo <= hi) {
int mid = lo + hi >> 1;
if(check(mid)) {
ans = mid, hi = mid - 1;
} else lo = mid + 1;
} printf("%d\n", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
