| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 399860 | nikatamliani | 구경하기 (JOI13_watching) | C++14 | 245 ms | 16068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
int a[N], dp[N][N], n, q, p;
void mini(int &x, int y) {
if(x > y) x = y;
}
bool check(int x) {
for(int i = 0; i < N; ++i) {
for(int j = 0; j < N; ++j) {
dp[i][j] = 1e9;
}
dp[0][i] = 0;
}
for(int i = 1; i <= n; ++i) {
int id0 = i-1, id1 = i-1;
while(id0 > 0 && a[i] - a[id0] + 1 <= x) --id0;
while(id1 > 0 && a[i] - a[id1] + 1 <= 2*x) --id1;
for(int j = 0; j <= p; ++j) {
dp[i][j] = dp[id1][j]+1;
if(j > 0) {
mini(dp[i][j], dp[id0][j-1]);
}
}
}
return dp[n][p] <= q;
}
int main() {
cin >> n >> p >> q;
if(p + q >= n) {
cout << 1 << '\n';
return 0;
}
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
sort(a+1, a+n+1);
int l = 1, r = 1e9, ans = -1;
while(r >= l) {
int m = l + r >> 1;
if(check(m)) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
}
cout << ans << endl;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
