| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 92647 | LittleFlowers__ | 구경하기 (JOI13_watching) | C++14 | 3 ms | 636 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=500010;
int n,p,q;
int a[N];
bool C(int x)
{
///2 ,11 ,17
int P=p,Q=q,i=1;
while(i<=n)
{
if(!P && !Q) return 0;
//cout<<i<<" "<<P<<" "<<Q<<"\n";
if(a[i]+x*2-1<a[i+1]) (P>0 ? P : Q)--,i++;
else
{
int u=-1,v=-1;
if(Q) u=upper_bound(a+1,a+n+1,a[i]+x*2-1)-a;
if(P) v=upper_bound(a+1,a+n+1,a[i]+x-1)-a;
//cout<<a[i] + x*2<<" "<<a[i+1]<<"\n";
if(u>v)
{
Q--;
i=u;
}
else
{
P--;
i=v;
}
}
}
return 1;
}
main()
{
//freopen("WATCHING.inp","r",stdin);
cin>>n>>p>>q;
for(int i=1;i<=n;++i) cin>>a[i];
sort(a+1,a+n+1);
int l=1,m,r=1e9,ans;
while(l<=r)
{
m=l+(r-l)/2;
if(C(m)) ans=m,r=m-1;
else l=m+1;
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
