QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#233110#2528. Mobile RobotBUET_Twilight#WA 0ms3896kbC++23739b2023-10-31 13:29:522023-10-31 13:29:53

Judging History

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

  • [2023-10-31 13:29:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3896kb
  • [2023-10-31 13:29:52]
  • 提交

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'