//#pns thut contains thragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 100005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = INT_MAX;
int n, k;
double t;
double pos[nmax];
bool check(double x ){
int l = k - 1 , r = k + 1 ;
double sum = t;
while( l >= 1 || r <= n ){
if( l == 0){
if( sum*x*2 >= (pos[r] - pos[r-1])){
sum += t - (pos[r] - pos[r-1])/(x*2);
r++;
}else{
return 0;
}
}
else if( r == n + 1){
if( sum*x*2 >= (pos[l+1] - pos[l])){
sum += t - (pos[l+1] - pos[l])/(x*2);
l--;
}else{
return 0;
}
}
else if( pos[l+1] - pos[l] >= pos[r] - pos[r-1]){
if( sum*x*2 >= (pos[r] - pos[r-1])){
sum += t - (pos[r] - pos[r-1])/(x*2);
r++;
}else{
return 0;
}
}else{
if( sum*x*2 >= (pos[l+1] - pos[l])){
sum += t - (pos[l+1] - pos[l])/(x*2);
l--;
}else{
return 0;
}
}
}
return 1;
}
int main(){
fast;
cin >> n >> k >> t;
forn(i,n){
cin >> pos[i];
}
if(pos[1] == pos[n]){cout << 0 << '\n';return 0;}
int l = 1 , r = 1e9;
while ( l < r){
int mid = (l+r)>>1;
if(check((double)mid)) r = mid;
else l = mid+1;
}
cout << r << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |