QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234676 | #2528. Mobile Robot | NYCU_gAwr_gurA# | TL | 0ms | 3968kb | C++20 | 973b | 2023-11-01 20:41:32 | 2023-11-01 20:41:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define endl '\n'
#define cerr if(1);else cerr
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
constexpr ld eps = 1e-5;
signed main() {
fast;
int n;
ll d;
cin >> n >> d;
vector<ll> v(n);
for (auto &x: v) cin >> x;
auto test = [&](ld m) {
ld l = v[0] - m, r = v[0] + m;
for (int i = 1; i < n; i++) {
l = max(l+d, v[i]-m);
r = min(r+d, v[i]+m);
if (l > r)
return false;
}
return l <= r;
};
ld l = 0, r = 3e16;
while ((r-l) > eps) {
ld m = (l+r) / 2;
if (test(m))
r = m;
else
l = m;
}
cout << fixed << setprecision(1) << l << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3968kb
input:
2 1 -1 1
output:
0.5
result:
ok single line: '0.5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 1 0 1
output:
0.0
result:
ok single line: '0.0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
2 1 0 0
output:
0.5
result:
ok single line: '0.5'
Test #4:
score: -100
Time Limit Exceeded
input:
2 1 -10000000000000000 10000000000000000