# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76330 | win11905 | 구경하기 (JOI13_watching) | C++11 | 1090 ms | 16888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+5;
int n, p, q;
int A[N];
int dp[N][N];
bool f(int m) {
memset(dp, 0, sizeof dp);
for(int i = 0; i <= p; ++i) for(int j = 0; j <= q; ++j) {
if(i == 0 and j == 0) continue;
if(i != 0) dp[i][j] = upper_bound(A+1, A+n+1, A[dp[i-1][j]+1] + m - 1) - A - 1;
if(j != 0) dp[i][j] = max((long int)dp[i][j], upper_bound(A+1, A+n+1, A[dp[i][j-1]+1] + m + m - 1) - A - 1);
if(dp[i][j] == n) return true;
}
return false;
}
int main() {
scanf("%d %d %d", &n, &p, &q);
if(p + q >= n) return puts("1"), 0;
for(int i = 1; i <= n; ++i) scanf("%d", A+i);
sort(A+1, A+n+1);
int l = 1, r = 1e9;
while(l < r) {
int m = l + r >> 1;
if(f(m)) r = m;
else l = m+1;
}
return !printf("%d\n", r);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |