QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282404 | #5505. Great Chase | tkrawczyk# | WA | 0ms | 4012kb | C++23 | 921b | 2023-12-11 22:39:07 | 2023-12-11 22:39:07 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define T long double
const T eps = 1e-9;
using namespace std;
void solve() {
int n, v; cin >> n >> v;
vector<pair<int, int>> h(n);
for(auto& [a, b] : h) {
cin >> a >> b;
}
T lo = 0, hi = 1e14;
const T oo = 1e18;
for(int r = 0; r < 70; r++) {
T mid = (lo + hi) / 2;
T najd = -oo;
T najbl = oo;
for(int i = 0; i < n; i++) {
if(h[i].first < 0) najd = max(najd, h[i].first + h[i].second * mid);
else najbl = min(najbl, h[i].first - h[i].second * mid);
}
if(najbl < najd) {
hi = mid;
}
else {
lo = mid;
}
}
cout << v * hi << '\n';
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(20);
int t; cin >> t;
while(t--) solve();
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4012kb
input:
3 4 9 10 2 -7 2 -6 1 7 1 2 8 -1 7 1 6 2 3 -1000000000000 1 1000000000000 1
output:
38.25000009110603171880 1.23076936554659954748 3000000000000.00000047683715820312
result:
wrong answer 2nd numbers differ - expected: '1.2307692', found: '1.2307694', error = '0.0000001'