이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
#define ld long double
int n, k, T;
vector <int> x;
bool can(int s){
int l, r;
l = r = k;
ld t = T;
auto calc = [&](ld d){
d /= 2;
return t - d / s;
};
while(l > 0 || r < n - 1){
ld new_t_l, new_t_r;
if(l > 0){
new_t_l = calc(x[l] - x[l - 1]);
}
else new_t_l = -1;
if(r < n - 1){
new_t_r = calc(x[r + 1] - x[r]);
}
else new_t_r = -1;
ld mx = max(new_t_l, new_t_r);
if(mx < 0) return 0;
if(new_t_l == mx){
l--;
t = new_t_l + T;
}
else{
r++;
t = new_t_r + T;
}
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> T;
x.resize(n);
for(auto &i : x) cin >> i;
k--;
if(x.back() - x[0] == 0) finish(0);
int l = 1, r = 1e9;
while(l <= r){
int mid = (l + r) / 2;
if(can(mid)) r = mid - 1;
else l = mid + 1;
}
cout << l << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |