QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#206445#5505. Great ChasedkdkWA 1ms3696kbC++201.7kb2023-10-07 20:33:312023-10-07 20:33:32

Judging History

This is the latest submission verdict.

  • [2023-10-07 20:33:32]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3696kb
  • [2023-10-07 20:33:31]
  • Submitted

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cmath>
#include <string>
#include <set>
#include <iomanip>
#define ft first
#define sd second
#define endl '\n'
#define lowbit(x) (x & (-x))
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using i128 = __int128;
const double eps = 1e-9;
const int N = 1010, mod = 998244353, INF = 2147483647;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};

int n;
double v;
vector<PDI> a, b;

bool check(double t)
{
    double xa = -1e18, xb = 1e18;
    for(auto o : a)
    {
        double p = o.ft, v = o.sd;
        xa = max(xa, p + v * t);
    }
    for(auto o : b)
    {
        double p = o.ft, v = o.sd;
        xb = min(xb, p - v * t);
    }

    if(xa > xb)return true;
    else return false;
}

void solve()
{
    cin >> n >> v;
    a.clear(), b.clear();
    for(int i = 0; i < n ; i++)
    {
        double x, y;
        cin >> x >> y;
        if(x < 0)a.push_back({x, y});
        else b.push_back({x, y});
    }

    double l = 0, r = 1e12;
    for(int i = 0; i < 50 ; i++)
    {
        double mid = (l + r) / 2;
        if(check(mid))r = mid;
        else l = mid;
    }

    //cout << l << ' ' << r << ' ' << eps << endl;
    cout << l * v << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    cout << setprecision(20);
    while(t -- )solve();
    return 0;
}
/*
3
4 9
10 2
-7 2
-6 1
7 1
2 8
-1 7
1 6
2 3
-1000000000000 1
1000000000000 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3696kb

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.249403644385893131
1.2292389328649733216
2999999999999.9975586

result:

wrong answer 1st numbers differ - expected: '38.2500000', found: '38.2494036', error = '0.0000156'