| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 59139 | RezwanArefin01 | 구경하기 (JOI13_watching) | C++17 | 147 ms | 16896 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 f(int pos, int tot) {
if(pos == n) return 0;
int &ret = dp[pos][p];
if(~ret) return ret;
ret = 1e9;
int x = lower_bound(a + pos, a + n, a[pos] + w) - a;
int y = lower_bound(a + pos, a + n, a[pos] + w + w) - a;
if(tot < p) ret = f(x, tot + 1);
return ret = min(ret, 1 + f(y, tot));
}
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) {
w = lo + hi >> 1;
memset(dp, -1, sizeof dp);
if(f(0, 0) <= q) {
ans = w, hi = w - 1;
} else lo = w + 1;
} printf("%d\n", ans);
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
