QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#127497#5593. Food Processorbatrr#AC ✓18ms4260kbC++171.9kb2023-07-19 18:54:352023-07-19 18:54:38

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-19 18:54:38]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:4260kb
  • [2023-07-19 18:54:35]
  • 提交

answer

#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = 300500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mult(int a, int b) {
    return 1ll * a * b % mod;
}

int bp(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return bp(x, mod - 2);
}
int s, t;
int n;
typedef long double ld;
void solve() {
    cin >> s >> t >> n;
    vector<pair<int,int>> ev;
    int st = 1e9;
    for (int i = 1; i <= n; i++) {
        int m, h;
        cin >> m >> h;
        if (m < t) {
            continue;
        }
        if (m >= s) {
            st = min(st, h);
            continue;
        }
        ev.emplace_back(m, h);
    }
    sort(ev.begin(), ev.end());
    reverse(ev.begin(), ev.end());
    int lst = s;
    ld ans = 0;
    if (st > 1e8) {
        cout << -1;
        return ;
    }
    for (int z = 0; z < ev.size(); z++) {
        if (ev[z].first < lst) {
            ans += log2l((ld)lst / ev[z].first) * st;
            lst = ev[z].first;
        }
        st = min(st, ev[z].second);
    }
    ans += log2l((ld)lst / t) * st;
    cout << fixed << setprecision(20) << ans;

}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
//        cout << "Case #" << i << endl;
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10 1 2
10 10
4 5

output:

23.21928094887362347895

result:

ok found '23.21928', expected '23.21928', error '0.00000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

10000 9999 1
10000 1

output:

0.00014427671804503527

result:

ok found '0.00014', expected '0.00014', error '0.00000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

10 1 2
8 10
4 5

output:

-1

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

8 2 1
8 10

output:

20.00000000000000000000

result:

ok found '20.00000', expected '20.00000', error '0.00000'

Test #5:

score: 0
Accepted
time: 12ms
memory: 4132kb

input:

1000000 1 100000
10 10
20 20
30 30
40 40
50 50
60 60
70 70
80 80
90 90
100 100
110 110
120 120
130 130
140 140
150 150
160 160
170 170
180 180
190 190
200 200
210 210
220 220
230 230
240 240
250 250
260 260
270 270
280 280
290 290
300 300
310 310
320 320
330 330
340 340
350 350
360 360
370 370
380 3...

output:

1442798.05087961463755164004

result:

ok found '1442798.05088', expected '1442798.05088', error '0.00000'

Test #6:

score: 0
Accepted
time: 9ms
memory: 4212kb

input:

1000000 1 100000
1000000 10
999990 20
999980 30
999970 40
999960 50
999950 60
999940 70
999930 80
999920 90
999910 100
999900 110
999890 120
999880 130
999870 140
999860 150
999850 160
999840 170
999830 180
999820 190
999810 200
999800 210
999790 220
999780 230
999770 240
999760 250
999750 260
99974...

output:

199.31568569324174113044

result:

ok found '199.31569', expected '199.31569', error '0.00000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

1000000 999999 1
1000000 1

output:

0.00000144269576223696

result:

ok found '0.00000', expected '0.00000', error '0.00000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

1000000 1 1
1000000 999999

output:

19931548.63775560476278769784

result:

ok found '19931548.63776', expected '19931548.63776', error '0.00000'

Test #9:

score: 0
Accepted
time: 18ms
memory: 3936kb

input:

500000 12345 100000
4783 477451
939177 624790
942796 933658
388835 943838
591586 528454
934640 609727
702473 355566
440638 181750
957421 781586
785155 972417
184923 378838
791637 199851
268779 962854
866409 181893
288522 536245
889062 89973
535331 469534
740453 750376
26154 41835
470536 449187
72774...

output:

77.58569700275615432794

result:

ok found '77.58570', expected '77.58570', error '0.00000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

100 90 2
100 100
50 50

output:

15.20030934450499849643

result:

ok found '15.20031', expected '15.20031', error '0.00000'

Test #11:

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

input:

500000 250000 100000
10 10
20 20
30 30
40 40
50 50
60 60
70 70
80 80
90 90
100 100
110 110
120 120
130 130
140 140
150 150
160 160
170 170
180 180
190 190
200 200
210 210
220 220
230 230
240 240
250 250
260 260
270 270
280 280
290 290
300 300
310 310
320 320
330 330
340 340
350 350
360 360
370 370
3...

output:

360678.76024628577118846806

result:

ok found '360678.76025', expected '360678.76000', error '0.00000'

Test #12:

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

input:

500000 250000 100000
1000000 10
999990 20
999980 30
999970 40
999960 50
999950 60
999940 70
999930 80
999920 90
999910 100
999900 110
999890 120
999880 130
999870 140
999860 150
999850 160
999840 170
999830 180
999820 190
999810 200
999800 210
999790 220
999780 230
999770 240
999760 250
999750 260
9...

output:

10.00000000000000007286

result:

ok found '10.00000', expected '10.00000', error '0.00000'

Test #13:

score: 0
Accepted
time: 9ms
memory: 3656kb

input:

339628 339627 100000
314958 825163
331735 186589
468575 663249
740875 177836
99223 104961
778511 480675
210189 875839
482518 443809
87641 132552
474668 793149
427516 585294
906229 831007
920684 701414
519835 999984
341304 6979
350365 969270
352553 515894
477624 900553
30125 692466
273123 237838
4419...

output:

0.00000424787462996959

result:

ok found '0.00000', expected '0.00000', error '0.00000'

Test #14:

score: 0
Accepted
time: 12ms
memory: 3696kb

input:

58690 58689 100000
149735 708833
357922 259234
650012 70684
242115 548483
566886 847642
716712 777996
685242 19268
805841 495873
378117 905396
876590 434890
677706 566233
760475 279669
969442 330292
662696 655431
496751 756379
297105 183079
246584 323524
411462 425463
502636 694072
214804 911995
101...

output:

0.00024581825384845102

result:

ok found '0.00025', expected '0.00025', error '0.00000'

Test #15:

score: 0
Accepted
time: 13ms
memory: 4260kb

input:

1000000 1 100000
927995 599233
513186 228014
167807 222161
576118 908019
753981 250002
963061 242671
902375 863934
904166 348093
5688 481133
539986 388979
408766 656716
130393 849902
134919 460875
609606 995320
470760 551884
498983 516924
769086 718544
531463 395229
599005 621028
183982 328716
16152...

output:

-1

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'