# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1147491 | gramathegod | Swimming competition (LMIO18_plaukimo_varzybos) | C++20 | 2093 ms | 320 KiB |
#include <bits/stdc++.h>
#define N 1e6
using namespace std;
int n,a,b;
int v[int(N)];
bool check(int ans){
deque<int> dq;
int index=a-1;
dq.push_back(-1);
while (index<n && !dq.empty()){
if (index-dq.front()>=a){
if (index-dq.front()<=b && v[index]-v[dq.front()+1]<=ans){
dq.push_back(index);
index++;
}
}
else{
index++;
}
}
return ((!dq.empty()) && (dq.back()==n-1));
}
int bin(){
int left=0, right=v[n-1]-v[0],mid;
int ans=right;
while (left<=right){
mid=(left+right)/2;
if (check(mid)){
ans=mid;
right=mid-1;
}
else{
left=mid+1;
}
}
return ans;
}
int main()
{
scanf("%d%d%d", &n,&a,&b);
printf("\n");
for (int i=0;i<n;i++){
scanf("%d", &v[i]);
}
sort(v,v+n);
cout<<bin();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |