# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138158 | rzbt | 구경하기 (JOI13_watching) | C++14 | 477 ms | 31992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 2005
typedef long long ll;
using namespace std;
ll n,p,q;
ll niz[MAXN];
ll dp[MAXN][MAXN];
bool provera(ll w){
for(ll i=0;i<MAXN;i++){
for(ll j=0;j<MAXN;j++){
dp[i][j]=10000000;
}
}
for(ll j=0;j<MAXN;j++){
dp[0][j]=0;
}
ll prosli=0,dprosli=0;
for(ll i=1;i<=n;i++){
while(niz[i]-niz[prosli+1]>=w)prosli++;
while(niz[i]-niz[dprosli+1]>=w+w)dprosli++;
dp[i][0]=1+dp[prosli][0];
for(ll j=1;j<=n;j++){
dp[i][j]=min(dp[dprosli][j-1],1+dp[prosli][j]);
}
}
if(dp[n][q]<=p)return true;
return false;
}
ll binarna(ll l,ll d,ll sol){
if(l>d)return sol;
ll mid=(l+d)/2;
if(provera(mid))return binarna(l,mid-1,mid);
return binarna(mid+1,d,sol);
}
int main()
{
scanf("%lld %lld %lld", &n, &p, &q);
for(ll i=1;i<=n;i++)scanf("%lld",niz+i);
sort(niz+1,niz+n+1);
p=min(p,n);
q=min(q,n);
printf("%lld",binarna(1,1e9+7,0));
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |