| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 765218 | yusuf12360 | 구경하기 (JOI13_watching) | C++14 | 3 ms | 352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
vector<int> a;
int n;
int binser(int x) {
int l=0, r=n-1, ans=0;
while(l<=r) {
int mid=l+r>>1;
if(a[mid]<x) ans=mid, l=mid+1;
else r=mid-1;
}
return ans;
}
bool can(int w, int p, int q) {
int idx=0;
while(idx<n) {
if(p>1 && q) {
int BIG=binser(a[idx]+2*w);
if(BIG==n-1) return 1;
int SMALL=binser(a[idx]+w);
if(SMALL==n-1) return 1;
SMALL=binser(a[SMALL+1]+w);
if(SMALL==n-1) return 1;
if(SMALL>BIG) p-=2, idx=SMALL;
else q--, idx=BIG;
} else if(p && q) {
int BIG=binser(a[idx]+2*w), SMALL=binser(a[idx]+w);
if(BIG==n-1 || SMALL==n-1) return 1;
if(BIG==SMALL) p--, idx=SMALL;
else q--, idx=BIG;
} else if(p) idx=binser(a[idx]+w), p--;
else if(q) idx=binser(a[idx]+2*w), q--;
else return 0;
idx++;
}
return 1;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int p, q; cin >> n >> p >> q;
a.resize(n);
for(int &p : a) cin >> p;
sort(a.begin(), a.end());
int l=1, r=1e9, w=1e9;
while(l<=r) {
int mid=l+r>>1;
if(can(mid, p, q)) w=mid, r=mid-1;
else l=mid+1;
}
cout << w << '\n';
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
