QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463944 | #2528. Mobile Robot | yzkkai# | WA | 0ms | 3820kb | C++20 | 755b | 2024-07-05 16:28:34 | 2024-07-05 16:28:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
inline void solve() {
int n;
LL d;
cin >> n >> d;
vector<LL> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
auto calc = [&] (vector<LL> x, int k) -> LL {
for (int i = 0; i < n; i++) {
a[i] += k * i * d;
}
sort(a.begin(), a.end());
return a[n - 1] - a[0];
};
LL res = min(calc(a, 1), calc(a, -1));
cout << res / 2;
if (res % 2 == 1) {
cout << ".5";
} else {
cout << ".0";
}
cout << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
2 1 -1 1
output:
0.5
result:
ok single line: '0.5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 1 0 1
output:
0.0
result:
ok single line: '0.0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
2 1 0 0
output:
0.5
result:
ok single line: '0.5'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
2 1 -10000000000000000 10000000000000000
output:
9999999999999999.5
result:
ok single line: '9999999999999999.5'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 10000000000 0 0
output:
5000000000.0
result:
ok single line: '5000000000.0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 10000000000 -10000000000000000 10000000000000000
output:
9999995000000000.0
result:
ok single line: '9999995000000000.0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3540kb
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: 3600kb
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'