# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25399 | khsoo01 | 구경하기 (JOI13_watching) | C++11 | 483 ms | 33472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
ll n, x[2005], a, b, na[2005], nb[2005];
ll dt[2005][2005];
bool can (ll P) {
for(ll i=1;i<=n;i++) {
na[i] = lower_bound(x+1, x+1+n, x[i]+P) - x - 1;
nb[i] = lower_bound(x+1, x+1+n, x[i]+2*P) - x - 1;
for(ll j=0;j<=i;j++) dt[i][j] = inf;
}
for(ll i=1;i<=n;i++) {
for(ll j=0;j<i;j++) {
dt[na[i]][j] = min(dt[na[i]][j], dt[i-1][j] + 1);
dt[nb[i]][j+1] = min(dt[nb[i]][j+1], dt[i-1][j]);
}
}
for(ll i=0;i<=b;i++) if(dt[n][i] <= a) return true;
return false;
}
int main()
{
scanf("%lld%lld%lld",&n,&a,&b);
if(a + b >= n) {puts("1"); return 0;}
for(ll i=1;i<=n;i++) scanf("%lld",&x[i]);
sort(x+1, x+1+n);
ll S = 1, E = inf;
while(S<E) {
ll M = (S+E)/2;
can(M) ? E = M : S = M+1;
}
printf("%lld\n",S);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |