QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#93565#5505. Great ChaseHCPS42#AC ✓1427ms9560kbC++171.4kb2023-04-01 17:00:272023-04-01 17:00:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-01 17:00:31]
  • 评测
  • 测评结果:AC
  • 用时:1427ms
  • 内存:9560kb
  • [2023-04-01 17:00:27]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/random>

using namespace std;

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

typedef long long ll;
typedef pair<int, int> pii;

__gnu_cxx::sfmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
std::ostream& operator << (std::ostream& os, const vector<T>& a) {
    for (const T& x : a) {
        os << x << ' ';
    }
    return os;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        int n;
        double V;
        cin >> n >> V;
        vector<double> p(n), v(n);
        for (int i = 0; i < n; ++i) {
            cin >> p[i] >> v[i];
        }
        double low = 0, high = 1e12;
        for (int it = 0; it < 100; ++it) {
            double mid = (low + high) / 2;
            double maxL = -1e12;
            double minR = 1e12;
            for (int i = 0; i < n; ++i) {
                if (p[i] < 0) {
                    maxL = max(maxL, p[i] + mid * v[i]);
                } else {
                    minR = min(minR, p[i] - mid * v[i]);
                }
            }
            if (maxL < minR) {
                low = mid;
            } else {
                high = mid;
            }
        }
        cout.precision(15);
        cout << low * V << '\n';
    }

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3692kb

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.25
1.23076923076923
3000000000000

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 763ms
memory: 3772kb

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.349
16414958969.7273
5202715639.83518
321977234.156326
45384199210.2217
183885744.769231
1708925225.23047
89786664971.5579
13924365606.2874
412975327.555556
965508404.512101
4703493416.28838
352961619.381044
5575125771.7988
341191687.000116
985544508.333187
1370541507.64871
143194575.07...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 1380ms
memory: 3856kb

input:

93
15435 968117
4196666 184
-5069875 255
-9782648 980
-1978138 176
9333323 764
-4323540 12
-8442049 319
-5371878 137
2881306 10
-4050629 133
-4659099 59
-5189169 320
-2256647 99
-3686648 37
1059255 33
-223142 20
8040933 408
8407764 705
694547 38
-7913614 746
-3573355 132
5919585 189
-3756662 94
-795...

output:

189662921.363636
197971181.333333
997533531.73763
6439673170.66574
993821598110.661
22727977326.4027
34702455207.5185
677770533.929817
46631726883.9691
5446481867.12903
11336247450.2721
4409370840.43913
15681606050.5763
14986614231.5469
1025909753.14299
18994454579.8465
105092139112.785
25758936825....

result:

ok 93 numbers

Test #4:

score: 0
Accepted
time: 1126ms
memory: 9560kb

input:

5
400000 999972
172811492468 106699
171900177092 102097
194121748377 184014
190302947556 172722
183121572232 149212
196566712700 190884
171376795991 99358
522927044000 159597
-129031052077 34395
189422320931 170012
-275879974024 638546
408864707565 98475
-106703244806 368801
192128798630 178213
2915...

output:

519985220219.812
511413015796.766
424240880533.634
518849481155.504
1882496988186.44

result:

ok 5 numbers

Test #5:

score: 0
Accepted
time: 1427ms
memory: 6668kb

input:

38
16668 999947
-3844782803 511
-210897941456 464872
618726004990 714384
-954596898686 225256
96675744 1148
-1515974078 11375
-206213840984 706184
306078847 3947
-474818331950 391451
-616022698917 561244
123378707 1540
-640636592655 406006
459201391325 908506
-733249583 5719
496163273 6238
619876911...

output:

89670748252.9786
98630840901.5076
29393530999.8943
50801000770.956
39668001027.2693
467846478226.411
30789914370.5743
23151476830.9051
51606123416.6258
151713060001.663
100944679009.609
766785664078.359
39969642788.0619
62341065938.36
323981604329.005
115228655021.122
52894567562.1791
83882295665.56...

result:

ok 38 numbers