QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#233110 | #2528. Mobile Robot | BUET_Twilight# | WA | 0ms | 3896kb | C++23 | 739b | 2023-10-31 13:29:52 | 2023-10-31 13:29:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1000006;
int ara[N];
int n,d;
bool pos(long double a){
long double l0 = ara[0]-a;
long double r0 = ara[0]+a;
for(int i=1;i<n;i++){
long double l2 = ara[i]-a;
long double r2 = ara[i]+a;
l2 = max(l2,l0+d);
r2 = min(r2,r0+d);
if( l2>r2 ) return false;
l0 = l2;
r0 = r2;
}
return true;
}
int main(){
long double l = 0;
long double r = 2*1e16;
cin>>n>>d;
for(int i=0;i<n;i++) cin>>ara[i];
for(int i=0;i<100;i++){
long double mid = (l+r)/2.;
if(pos(mid)) r = mid;
else l = mid;
}
cout<<fixed<<setprecision(1)<<r<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
2 1 -1 1
output:
0.5
result:
ok single line: '0.5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
2 1 0 1
output:
0.0
result:
ok single line: '0.0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
2 1 0 0
output:
0.5
result:
ok single line: '0.5'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3880kb
input:
2 1 -10000000000000000 10000000000000000
output:
1073741823.5
result:
wrong answer 1st lines differ - expected: '9999999999999999.5', found: '1073741823.5'