QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233115#2528. Mobile RobotBUET_Twilight#WA 0ms3884kbC++23798b2023-10-31 13:34:142023-10-31 13:34:15

Judging History

你现在查看的是最新测评结果

  • [2023-10-31 13:34:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3884kb
  • [2023-10-31 13:34:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const long double eps = 1e-9;
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>eps ) return false;
        l0 = l2;
        r0 = r2;
    }
    return true;
}

signed main(){
    long double l = 0;
    long double r = 1e18;
    cin>>n>>d;
    for(int i=0;i<n;i++) cin>>ara[i];
    for(int i=0;i<200;i++){
        long double mid = (l+r)/2.;
        if(pos(mid)) r = mid;
        else l = mid;
    }
    cout<<fixed<<setprecision(1)<<r<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3756kb

input:

2 1
-1 1

output:

0.5

result:

ok single line: '0.5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

2 1
0 1

output:

0.0

result:

ok single line: '0.0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

2 1
0 0

output:

0.5

result:

ok single line: '0.5'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

2 1
-10000000000000000 10000000000000000

output:

9999999999999999.5

result:

ok single line: '9999999999999999.5'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

2 10000000000
0 0

output:

5000000000.0

result:

ok single line: '5000000000.0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

2 10000000000
-10000000000000000 10000000000000000

output:

9999995000000000.0

result:

ok single line: '9999995000000000.0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

10 1
0 1 2 3 4 5 6 7 8 9

output:

0.0

result:

ok single line: '0.0'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3800kb

input:

10 1
9 8 7 6 5 4 3 2 1 0

output:

9.0

result:

wrong answer 1st lines differ - expected: '0.0', found: '9.0'