QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524196#4233. ResetLittleCubeWA 2994ms18524kbC++171.4kb2024-08-19 12:07:062024-08-19 12:07:07

Judging History

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

  • [2024-08-19 12:07:07]
  • 评测
  • 测评结果:WA
  • 用时:2994ms
  • 内存:18524kb
  • [2024-08-19 12:07:06]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pl3 tuple<ll, ll, ll>
#define pdd pair<double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

ll N, C, D[200005], T[200005];
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> N >> C;
    for (int i = 1; i <= N; i++)
        cin >> T[i] >> D[i];
    // k days: k - 1 free days + 1 complete day
    auto check = [&](ll k)
    {
        ll remain = k * C, over = 0, total = 0;
        priority_queue<pl3> pq;
        for (int i = 1; i <= N; i++)
            pq.push(make_tuple(D[i], T[i], k));
        while (!pq.empty())
        {
            auto [d, t, u] = pq.top();
            pq.pop();
            ll use = min({u, remain, t / d});
            u -= use, remain -= use, t -= use * d; 
            if (u == 0)
                over++, total += t;
            else if (remain == 0)
                total += t;
            else if (t > 0) // arrive at last remainder
                pq.push(make_tuple(min(d, t), t, u));
        }
        total += max(over, C - remain);
        return total <= C;
    };
    ll l = 1, r = (N * 2e9) / C;
    while (l < r)
    {
        ll mid = (l + r) / 2;
        if (check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    cout << l - 1 << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 5
17 5
5 2
15 4

output:

3

result:

ok single line: '3'

Test #2:

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

input:

2 1345
1344 1
10 10

output:

0

result:

ok single line: '0'

Test #3:

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

input:

1 1000000000
1000000000 1

output:

0

result:

ok single line: '0'

Test #4:

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

input:

3 2345
333 1
444 2
555 3

output:

0

result:

ok single line: '0'

Test #5:

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

input:

1 500
1000 2

output:

250

result:

ok single line: '250'

Test #6:

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

input:

1 499
1000 2

output:

250

result:

ok single line: '250'

Test #7:

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

input:

3 2345
3333 5
4444 6
5555 6

output:

646

result:

ok single line: '646'

Test #8:

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

input:

8 6
40 10
40 10
40 10
40 10
40 10
20 5
4 3
5 3

output:

4

result:

ok single line: '4'

Test #9:

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

input:

8 6
40 10
40 10
40 10
40 10
40 10
20 5
7 3
5 3

output:

4

result:

ok single line: '4'

Test #10:

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

input:

5 4
29 8
30 7
2000 1000
2000 1000
2000 1000

output:

3

result:

ok single line: '3'

Test #11:

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

input:

27 19
21 5
14 5
14 5
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000

output:

4

result:

ok single line: '4'

Test #12:

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

input:

24 21
25 8
13 7
13 7
13 7
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000
3000 1000

output:

3

result:

ok single line: '3'

Test #13:

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

input:

4 2
10 10
10 10
10 10
9 2

output:

3

result:

ok single line: '3'

Test #14:

score: 0
Accepted
time: 251ms
memory: 11348kb

input:

110000 60000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 100000
222200000 10000...

output:

99999

result:

ok single line: '99999'

Test #15:

score: 0
Accepted
time: 430ms
memory: 17572kb

input:

200000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
1000000000 1
10000...

output:

199999999999999

result:

ok single line: '199999999999999'

Test #16:

score: 0
Accepted
time: 2986ms
memory: 17260kb

input:

200000 7
966486041 28
936158040 29
991239679 47
988279269 31
905558493 68
998009820 40
901181342 66
925252807 10
995161072 3
947576761 21
980670741 66
931584704 3
944714227 42
992178536 6
905079737 39
982672468 87
963094272 21
919244645 48
935633595 3
903091417 4
923453539 72
916293313 82
981382022 ...

output:

1405907290168

result:

ok single line: '1405907290168'

Test #17:

score: 0
Accepted
time: 2622ms
memory: 17272kb

input:

200000 313
955333176 37
901868728 50
941539297 29
986447408 44
991503201 16
960466782 13
941404760 26
906572773 27
983407691 42
968036098 75
978785905 2
930572618 67
968054047 14
972769762 39
903513789 23
966791626 84
992080584 65
976672158 15
912399245 35
961103319 25
920979048 64
959902065 72
9685...

output:

31397952846

result:

ok single line: '31397952846'

Test #18:

score: 0
Accepted
time: 2115ms
memory: 18524kb

input:

200000 10
23 21
17 5
5 5
9 2
29 24
14 7
24 23
30 8
10 10
29 27
1 1
3 2
18 7
17 12
26 3
13 6
7 4
28 20
5 1
16 3
24 5
22 4
27 11
11 5
1 1
12 4
1 1
12 3
30 5
26 24
11 9
21 19
1 1
4 4
8 1
29 22
10 8
3 1
24 12
7 7
25 18
11 10
20 19
20 19
20 10
27 26
2 2
12 7
24 18
19 15
19 10
11 4
12 4
2 1
27 9
3 3
19 5
...

output:

70162

result:

ok single line: '70162'

Test #19:

score: 0
Accepted
time: 1807ms
memory: 17208kb

input:

200000 10
4 1
8 4
11 4
15 2
3 3
7 3
14 3
27 4
17 4
4 4
11 5
19 1
29 4
9 5
2 1
30 5
5 1
27 5
20 2
6 5
3 3
30 3
18 2
13 5
16 3
21 3
8 3
17 4
10 5
16 3
8 2
16 3
8 4
4 4
2 2
8 3
30 4
15 1
21 3
19 3
12 5
3 1
23 2
9 3
15 5
4 2
11 3
15 4
5 3
1 1
28 2
12 3
15 3
5 1
6 5
3 1
4 3
18 2
26 4
29 5
7 3
19 2
13 1
1...

output:

147252

result:

ok single line: '147252'

Test #20:

score: 0
Accepted
time: 1962ms
memory: 18404kb

input:

200000 100
18 11
12 3
10 6
28 26
17 2
2 2
6 5
15 12
18 7
26 8
29 18
6 1
20 10
14 4
3 2
3 2
4 2
7 6
7 4
9 2
21 19
11 8
23 19
3 2
10 10
17 12
24 21
12 10
30 22
29 17
12 5
5 4
9 3
20 12
7 6
17 5
5 5
30 4
8 2
29 1
30 25
16 13
25 23
2 1
24 23
10 3
10 10
7 4
24 13
1 1
26 26
3 2
10 3
17 6
14 7
28 18
3 1
17...

output:

7021

result:

ok single line: '7021'

Test #21:

score: 0
Accepted
time: 1695ms
memory: 17624kb

input:

200000 100
3 2
6 3
18 4
14 5
4 1
1 1
25 1
22 1
15 1
2 2
16 2
3 2
11 2
29 4
21 3
13 2
4 1
7 3
13 5
5 2
13 3
19 2
8 3
3 2
22 3
16 1
28 1
26 4
19 3
7 5
22 1
10 3
19 1
5 3
2 2
18 1
5 1
16 2
12 3
20 1
12 5
25 5
20 3
23 2
17 4
30 3
24 1
24 4
16 1
18 1
21 3
9 4
7 5
28 4
1 1
15 2
24 3
1 1
14 1
26 1
27 3
28 ...

output:

14737

result:

ok single line: '14737'

Test #22:

score: 0
Accepted
time: 1770ms
memory: 17176kb

input:

200000 1000
13 1
29 7
22 15
17 12
30 25
20 7
28 12
13 13
8 5
22 7
9 6
20 15
2 2
23 16
13 2
21 1
27 9
1 1
13 5
18 9
28 2
28 8
12 12
10 6
2 2
19 16
4 4
14 14
10 5
7 1
16 16
26 14
5 2
20 12
5 5
3 3
10 7
22 21
7 6
4 3
21 17
22 12
7 5
6 6
17 6
16 6
30 6
22 4
29 16
4 3
29 3
26 17
21 15
21 20
14 13
27 24
1...

output:

698

result:

ok single line: '698'

Test #23:

score: 0
Accepted
time: 1603ms
memory: 18016kb

input:

200000 1000
27 5
2 2
29 4
9 2
16 4
15 3
29 3
1 1
21 2
2 1
21 3
17 4
12 2
26 2
1 1
8 5
29 2
5 3
4 3
9 4
5 5
30 2
11 4
20 5
25 1
22 2
21 1
1 1
5 2
13 4
26 1
5 2
7 3
21 2
27 5
17 3
24 2
25 1
26 4
15 2
5 1
15 5
26 2
6 5
27 4
3 1
19 5
27 4
24 5
3 1
17 4
25 5
1 1
20 2
22 4
12 5
1 1
6 3
25 1
15 1
22 2
10 2...

output:

1474

result:

ok single line: '1474'

Test #24:

score: 0
Accepted
time: 891ms
memory: 17192kb

input:

200000 998642531
14 6
13 3
2 1
9 6
15 12
10 1
11 9
21 13
23 8
29 8
28 26
1 1
27 5
17 3
14 14
22 11
27 19
5 2
9 3
2 1
11 4
9 3
8 5
28 12
12 7
29 12
19 5
29 16
24 3
20 10
2 2
6 3
9 5
6 4
3 2
18 3
16 3
27 5
14 14
29 23
21 17
22 13
1 1
13 2
21 7
13 1
21 16
11 1
18 8
28 17
14 6
24 8
30 15
29 4
4 2
13 12
...

output:

0

result:

ok single line: '0'

Test #25:

score: 0
Accepted
time: 2994ms
memory: 18388kb

input:

200000 10
3684 3080
3014 1370
3226 2869
4168 3400
3744 45
4280 670
4898 1215
4699 1387
3103 2201
4357 1267
4602 1765
3290 1180
3556 3370
4198 3434
3743 3324
4592 4451
3328 2499
4848 2244
3879 2853
3676 2630
4758 3917
3057 1758
3045 279
4784 3965
4530 4183
4435 1460
3239 978
4034 269
4046 3652
3626 2...

output:

188403

result:

ok single line: '188403'

Test #26:

score: 0
Accepted
time: 2779ms
memory: 17172kb

input:

200000 100
3019 973
3932 1011
3415 2658
3428 2971
3566 1447
4647 2270
4083 135
3876 3207
3505 2148
3979 3087
3314 1757
3116 1
3785 3297
3220 2212
3585 3462
3583 3195
4654 3563
3951 704
3535 1229
3941 1769
3804 3085
4218 1581
3241 2950
3445 2551
4753 25
4583 1820
4466 2945
3572 2641
3500 503
4403 180...

output:

18881

result:

ok single line: '18881'

Test #27:

score: 0
Accepted
time: 2778ms
memory: 18104kb

input:

200000 100
3294 37
3313 44
3463 9
3349 46
4444 11
3206 16
3046 16
3592 32
4838 50
4871 40
3105 8
3646 41
4136 30
4592 3
4921 2
3218 24
4452 30
3038 5
3604 22
4593 7
4475 20
3372 16
3014 19
4959 42
4863 45
3607 31
4304 48
3682 25
3651 16
3586 10
3478 17
4524 25
4611 41
4411 47
3228 14
3786 35
4114 50...

output:

721052

result:

ok single line: '721052'

Test #28:

score: 0
Accepted
time: 2540ms
memory: 17172kb

input:

200000 1000
3760 3035
4707 305
3581 1906
4963 787
4825 3243
3176 750
4163 45
3109 1115
3249 864
4367 3432
3858 1478
3291 689
3421 2877
3092 719
4735 3136
4462 781
3092 2834
3907 1499
4234 4135
3777 1128
4546 1996
3986 1907
4808 4629
4907 4167
3770 947
3589 173
3438 1497
4594 4389
3067 1223
4668 4087...

output:

4698

result:

ok single line: '4698'

Test #29:

score: 0
Accepted
time: 2343ms
memory: 18336kb

input:

200000 10000
4431 3806
4004 3485
4665 4535
4410 1029
4584 2925
3215 1749
4461 951
4201 2434
4443 2307
3258 2988
4546 3074
4069 2626
4667 4586
3063 1858
3278 1795
4560 2041
4515 260
4444 2831
3153 385
3009 750
4856 2376
4353 254
3732 976
3182 1612
4532 3688
4914 1417
4069 2048
3685 1402
4836 2445
396...

output:

3945

result:

ok single line: '3945'

Test #30:

score: 0
Accepted
time: 2323ms
memory: 18160kb

input:

200000 10000
3194 48
3378 17
3107 14
4004 6
3831 9
3375 8
3905 37
3754 29
3266 29
4651 40
3595 32
4108 40
3628 6
3380 34
3178 20
4693 9
3009 29
4761 24
3780 42
3042 20
3883 18
3781 1
3842 38
3928 7
4488 3
3356 50
4688 21
4491 39
4975 18
3956 40
4507 2
3495 27
4731 5
4749 38
3919 10
3622 10
3765 17
4...

output:

7243

result:

ok single line: '7243'

Test #31:

score: 0
Accepted
time: 1199ms
memory: 17168kb

input:

200000 936459299
4490 3508
4411 4089
4574 4346
4986 1762
3949 1395
3817 3130
3275 1494
4886 1288
4544 4241
3712 1588
3010 1570
4783 4359
3234 1613
4026 2009
4232 2940
3686 3313
4500 2835
4180 751
4052 679
4901 990
3927 344
3814 2690
4155 1765
3002 846
4694 326
4218 3048
4532 518
4716 1771
3687 3293
...

output:

0

result:

ok single line: '0'

Test #32:

score: -100
Wrong Answer
time: 564ms
memory: 17180kb

input:

200000 984365240
948008790 4
917968673 5
916371433 1
920084719 5
961214689 4
978284904 2
951405682 2
988955890 3
956391151 2
935114279 4
946380955 5
908225059 3
930643776 2
948070216 1
936295824 2
979801389 4
954164107 2
957063005 3
929215803 1
998330260 4
987902706 3
926594054 4
975993529 3
9004574...

output:

406352

result:

wrong answer 1st lines differ - expected: '997761885', found: '406352'