| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1344093 | minhtien | 구경하기 (JOI13_watching) | C++20 | 3 ms | 348 KiB |
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
const int inf=1e9+7;
int a[N];
int n,p,q;
int f(){
int tong=inf;
int l=1,r=inf;
while(l<=r){
int m=(l+r)/2;
int tong1=p,tong2=q;
int j=1;
for(int i=1;i<=n;i++){
// if(m==3){
// cout << "* " << i << "\n";
// }
if(tong1>=1 && tong2>=1){
int t=upper_bound(a+1,a+1+n,a[i]+m-1)-a;
int t1=upper_bound(a+1,a+1+n,a[i]+2*m-1)-a;
int tong3=t-i,tong4=t1-i;
if(tong3==tong4){
tong1--;
i=t-1;
j=i;
}
else{
tong2--;
i=t1-1;
j=i;
}
// if(m==3){
// cout << "* " << j << " " << tong2 << "\n";
// }
}
else if(tong1>=1 && tong2<=0){
int t=upper_bound(a+1,a+1+n,a[i]+m-1)-a;
tong1--;
i=t-1;
j=i;
}
else if(tong1<=0 && tong2>=1){
int t1=upper_bound(a+1,a+1+n,a[i]+2*m-1)-a;
tong2--;
i=t1-1;
j=i;
}
}
// cout << " " << m << " " << j << "\n";
if(j==n){
tong=min(tong,m);
r=m-1;
}
else{
l=m+1;
}
}
return tong;
}
int main()
{
cin >>n >>p >>q;
for(int i=1;i<=n;i++){
cin >> a[i];
}
sort(a+1,a+1+n);
int s2=f();
cout << s2;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
