QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#165623#5505. Great Chasearseny_y#WA 834ms4024kbC++231.5kb2023-09-05 19:59:512023-09-05 19:59:52

Judging History

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

  • [2023-09-05 19:59:52]
  • 评测
  • 测评结果:WA
  • 用时:834ms
  • 内存:4024kb
  • [2023-09-05 19:59:51]
  • 提交

answer

//I wrote this code 4 u today
#include <bits/stdc++.h>

template<class t> using vc = std::vector<t>;

#define nd node*
#define pnd pair<nd, nd>

typedef long long ll;

template<const ll MOD>
struct mod_mul : std::multiplies<const ll> {
    ll operator()(const ll a, const ll b) {
        return (a * b) % MOD;
    }
};


template<typename T>
inline void sort(T &a) {
    std::sort(a.begin(), a.end());
}

template<typename T>
inline void unique(T &a) {
    a.resize(std::unique(a.begin(), a.end()) - a.begin());
}

template<typename T>
inline void reverse(T &a) {
    std::reverse(a.begin(), a.end());
}

const ll INF = 9023372036854775808ll;
const ll MOD = 1000000007ll;

typedef long double ld;

int main() {
    std::cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(18);
    int z;
    std::cin >> z;
    while (z--) {
        ll n, v;
        std::cin >> n >> v;
        vc<std::pair<ll, ll>> p(n);
        for (auto &i : p) std::cin >> i.first >> i.second;
        ld l = 0, r = 16e16 + 5;
        for (int i = 0; i < 120; ++i) {
            ld mid = (l + r) / 2.0;
            ld mn = 1e9 + 5, mx = -1e9 - 5;
            for (auto [p, v] : p) if (p > 0) mn = std::min(mn, p - v * mid);
            for (auto [p, v] : p) if (p < 0) mx = std::max(mx, p + v * mid);
            if (mn <= mx) r = mid;
            else l = mid;
        }
        std::cout << r * v << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

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.250000000000000000
1.230769230769230769
3000000000000.000000000000000000

result:

ok 3 numbers

Test #2:

score: -100
Wrong Answer
time: 834ms
memory: 4024kb

input:

10000
200 997007
405524182320 754760
686939601648 419804
687047488212 715566
1446157132 4594
-670522037 4673
763634629282 253755
424307411732 275041
1582708381 8473
-667425982 4622
-522841486 1427
702430907988 460271
1405423646 1060
1497754648 6227
883363410675 723547
56899800372 46435
-810216390 64...

output:

145405766328.349110037088394165
13327263111.681863346137106419
5202715639.835183900315314531
321977234.156325868971180171
30884279881.566518846899271011
183885744.769230769234127365
1708925225.230472357943654060
60011897900.503370206803083420
13074863751.755216490477323532
412975327.5555555555620230...

result:

wrong answer 2nd numbers differ - expected: '16414958969.7272797', found: '13327263111.6818638', error = '0.1881026'