QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282404#5505. Great Chasetkrawczyk#WA 0ms4012kbC++23921b2023-12-11 22:39:072023-12-11 22:39:07

Judging History

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

  • [2023-12-11 22:39:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4012kb
  • [2023-12-11 22:39:07]
  • 提交

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'