QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234680#2528. Mobile RobotNYCU_gAwr_gurA#WA 0ms3968kbC++201006b2023-11-01 20:45:332023-11-01 20:45:33

Judging History

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

  • [2023-11-01 20:45:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3968kb
  • [2023-11-01 20:45:33]
  • 提交

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>;

signed main() {
    fast;

    int n;
    ll d;
    cin >> n >> d;
    vector<ll> v(n);
    for (auto &x: v) cin >> x;

    d *= 100;
    for (auto &x: v) x *= 100;

    auto test = [&](ll m) {
        ll 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;
    };

    ll l = 0, r = 3e16 * 100;
    while (l < r) {
        ll m = (l+r) / 2;
        if (test(m))
            r = m;
        else
            l = m+1;
    }

    cout << fixed << setprecision(1) << (l / 100.0) << endl;

    return 0;
}

详细

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: 3832kb

input:

2 1
0 1

output:

0.0

result:

ok single line: '0.0'

Test #3:

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

input:

2 1
0 0

output:

0.5

result:

ok single line: '0.5'

Test #4:

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

input:

2 1
-10000000000000000 10000000000000000

output:

10000000000000000.0

result:

wrong answer 1st lines differ - expected: '9999999999999999.5', found: '10000000000000000.0'