QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#335806#4077. 뚫기tuanlinh12329 248ms8920kbC++203.6kb2024-02-23 23:44:122024-02-23 23:44:12

Judging History

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

  • [2024-02-23 23:44:12]
  • 评测
  • 测评结果:29
  • 用时:248ms
  • 内存:8920kb
  • [2024-02-23 23:44:12]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

const ll inf=1e18;
struct SegTree
{
    struct Node
    {
        ll lzs=0;
        pll Min={0, 0}, lzm={inf, 0};
        Node(ll type=0) {if (type) Min.fi=inf;}

        Node operator + (const Node &o) const
        {
            Node ans; 
            ans.Min=min(Min, o.Min);
            return ans;
        }

        void act(ll ad, pll mi)
        {
            Min.fi+=ad, Min=min(Min, mi);
            lzs+=ad, lzm.fi+=ad, lzm=min(lzm, mi);
        }
    };

    ll n;
    vector <Node> St;
    SegTree (ll n): n(n) {St.resize(n*4+1);}
    
    void Move(ll i)
    {
        St[i*2].act(St[i].lzs, St[i].lzm);
        St[i*2+1].act(St[i].lzs, St[i].lzm);
        St[i].lzs=0, St[i].lzm={inf, 0};
    }

    void update(ll i, ll Start, ll End, ll l, ll r, ll ad, pll mi)
    {
        if (Start>r || End<l) return;
        if (Start>=l && End<=r) {St[i].act(ad, mi); return;}
        ll mid=(Start+End)/2; Move(i);
        if (l<=mid) update(i*2, Start, mid, l, r, ad, mi);
        if (r>=mid+1) update(i*2+1, mid+1, End, l, r, ad, mi);
        St[i]=St[i*2]+St[i*2+1];
    }
    void update(ll l, ll r, ll ad, pll mi) {update(1, 1, n, l, r, ad, mi);}

    Node query(ll i, ll Start, ll End, ll l, ll r)
    {
        if (Start>r || End<l) return Node(1);
        if (Start>=l && End<=r) return St[i];
        ll mid=(Start+End)/2; Move(i);
        if (l>mid) return query(i*2+1, mid+1, End, l, r);
        if (r<mid+1) return query(i*2, Start, mid, l, r);
        return query(i*2, Start, mid, l, r)+query(i*2+1, mid+1, End, l, r);
    }
    Node query(ll l, ll r) {return query(1, 1, n, l, r);}
};

ll n, m, l[10005], r[10005];
void init(int N, int M, vector <int> L, vector <int> R)
{
    n=N, m=M;
    for (ll i=0; i<n; i++)
        l[i]=L[i], r[i]=R[i];
    //compress numbers
    {
        vector <ll> num; num.pb(0);
        for (ll i=0; i<n; i++)
        {
            num.pb(l[i]), num.pb(r[i]);
            if (r[i]<m-1) num.pb(r[i]+1);
        }
        sort(num.begin(), num.end());
        num.resize(unique(num.begin(), num.end())-num.begin());
        for (ll i=0; i<n; i++)
        {
            l[i]=lower_bound(num.begin(), num.end(), l[i])-num.begin()+1;
            r[i]=lower_bound(num.begin(), num.end(), r[i])-num.begin()+1;
        }
        m=num.size();
    }
    auto Try=[&](ll A, ll B)
    {
        SegTree S(m);
        for (ll i=0; i<n; i++)
        {
            S.update(l[i], r[i], B, {inf, 0});
            SegTree::Node best=S.query(1, m); 
            S.update(1, m, 0, {best.Min.fi+A, best.Min.se+1});
        }
        ll cost, a, b;
        tie(cost, a)=S.query(1, m).Min, b=(cost-a*A)/B;
        return mp(a, b);
    };
}

ll minimize(int A, int B)
{
    SegTree S(m);
    for (ll i=0; i<n; i++)
    {
        S.update(l[i], r[i], B, {inf, 0});
        SegTree::Node best=S.query(1, m); 
        S.update(1, m, 0, {best.Min.fi+A, best.Min.se+1});
    }
    return S.query(1, m).Min.fi;
}

// int main()
// {
//     ios_base::sync_with_stdio(0);
//     cin.tie(0); cout.tie(0);
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
//     ll n, m, q; cin >> n >> m >> q;
//     vector <int> l(n), r(n);
//     for (ll i=0; i<n; i++)
//         cin >> l[i] >> r[i];
//     init(n, m, l, r);
//     for (ll i=0; i<q; i++)
//     {
//         ll A, B; cin >> A >> B;
//         cout << minimize(A, B) << "\n";
//     }
// }

詳細信息

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 3520kb

input:

6 2 1
1 1
0 1
0 0
0 1
1 1
0 1
724642704 32998300

output:

131993200

result:

ok single line: '131993200'

Test #2:

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

input:

10 3 1
1 2
1 2
0 2
1 2
2 2
0 2
1 1
0 2
0 1
1 2
686137157 255736273

output:

1022945092

result:

ok single line: '1022945092'

Test #3:

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

input:

50 5 1
0 1
4 4
3 4
1 4
0 3
1 4
1 3
0 4
0 0
0 3
0 1
0 3
0 0
2 3
0 0
3 4
1 1
2 2
0 1
0 1
0 4
1 4
3 4
0 1
0 4
2 2
0 3
0 3
0 4
0 3
0 4
2 4
0 0
4 4
3 3
1 4
2 3
0 2
0 1
0 3
2 3
3 3
2 3
2 4
2 2
0 2
1 2
0 4
1 3
2 4
404445464 361978179

output:

6196096328

result:

ok single line: '6196096328'

Test #4:

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

input:

121 7 1
2 5
5 6
1 6
0 6
4 5
1 6
2 4
2 4
0 6
2 6
1 5
3 4
0 4
1 6
0 2
0 5
2 6
1 6
1 2
1 4
0 6
1 5
0 5
0 6
0 6
0 6
1 4
0 4
3 5
1 6
0 0
0 5
1 3
0 6
0 3
1 3
1 2
2 3
0 5
1 4
2 4
0 5
0 0
1 3
1 6
0 2
1 6
2 5
2 4
0 6
1 2
2 4
3 4
0 5
0 6
0 6
1 6
0 6
0 4
2 6
0 1
0 2
0 3
0 5
3 6
2 4
4 4
1 6
5 5
0 4
0 5
0 0
2 3
...

output:

16848723090

result:

ok single line: '16848723090'

Test #5:

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

input:

243 9 1
0 7
1 7
0 3
3 7
1 8
5 6
4 6
3 5
5 6
0 6
0 8
1 8
7 8
4 8
1 8
0 5
3 3
5 8
5 7
8 8
3 6
0 6
4 4
1 3
0 7
2 5
0 2
6 6
4 7
1 3
0 8
1 4
0 8
2 8
6 8
5 8
1 8
0 8
7 8
3 3
3 4
0 8
6 8
0 4
2 8
0 8
1 7
0 6
4 4
1 8
6 8
0 7
4 8
0 8
1 5
4 7
0 8
3 3
1 1
5 8
1 4
5 7
3 4
1 7
1 8
1 8
6 8
0 4
0 8
2 8
3 7
2 8
0 3
...

output:

27719095584

result:

ok single line: '27719095584'

Test #6:

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

input:

1000 102 1
46 74
33 80
4 84
22 96
1 100
10 36
35 68
0 65
4 26
26 93
25 90
0 79
14 101
24 57
4 53
37 60
4 77
32 97
44 70
29 65
44 99
2 49
0 86
69 76
3 57
1 93
16 83
38 60
1 86
1 40
19 97
28 94
4 45
16 72
23 94
26 89
20 60
29 32
21 39
14 83
26 74
24 77
15 88
72 93
12 90
1 81
27 60
15 90
36 78
18 39
12...

output:

23789206007

result:

ok single line: '23789206007'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

2000 123 1
48 81
27 95
16 109
19 106
26 115
4 116
66 83
2 111
39 118
15 47
21 122
1 120
78 101
35 120
55 95
36 59
75 75
42 64
71 105
11 121
31 122
30 112
93 116
1 61
77 84
26 90
28 109
14 116
9 118
80 91
8 101
13 113
29 51
2 118
5 77
23 93
25 108
3 120
8 120
22 64
36 65
7 83
7 115
14 93
8 50
7 116
5...

output:

40092503040

result:

ok single line: '40092503040'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3976kb

input:

3000 143 1
0 142
28 140
36 139
27 48
1 137
21 142
35 103
40 91
55 82
2 135
27 123
42 58
38 126
105 106
43 65
13 103
78 99
71 102
21 106
94 127
31 40
14 131
94 120
1 117
5 128
48 120
27 135
31 107
49 107
2 132
89 102
22 123
23 139
76 137
125 136
80 122
12 127
17 91
84 136
82 139
45 131
38 85
9 142
24...

output:

53183710390

result:

ok single line: '53183710390'

Test #9:

score: 0
Accepted
time: 2ms
memory: 4052kb

input:

3000 123 1
38 120
3 97
6 57
11 11
29 76
39 115
69 89
57 122
11 122
43 66
46 104
6 43
4 119
8 59
28 107
73 102
18 119
70 108
62 95
4 115
19 79
29 91
2 40
114 120
67 83
37 46
14 110
4 70
2 35
35 120
21 28
20 111
4 121
10 103
7 122
36 105
21 28
15 26
54 72
65 113
24 118
58 115
49 115
13 112
105 120
0 1...

output:

9990597533

result:

ok single line: '9990597533'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3980kb

input:

3000 102 1
94 95
51 101
91 99
9 92
8 80
2 60
45 57
1 96
40 83
8 8
15 87
10 98
44 89
40 96
13 62
4 67
6 35
0 101
36 95
15 53
56 86
55 88
38 74
11 50
0 61
0 93
32 69
7 60
32 82
9 98
7 97
18 100
70 91
26 80
27 101
21 69
0 101
43 49
45 97
17 73
1 12
0 36
40 86
44 92
57 68
15 87
57 68
54 75
66 101
10 88
...

output:

69226624268

result:

ok single line: '69226624268'

Test #11:

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

input:

3000 6 1
4 4
5 5
2 2
0 5
3 3
0 5
0 4
1 4
0 2
0 4
1 5
1 5
0 3
4 5
2 3
1 5
1 3
3 5
0 3
3 3
3 5
1 3
2 2
1 5
0 1
3 4
2 4
0 0
4 4
0 2
1 4
3 4
1 3
0 1
0 1
0 0
2 4
0 2
0 4
2 5
0 5
0 4
0 1
0 3
1 5
2 4
2 4
0 5
2 5
3 4
0 5
1 5
4 5
2 4
1 1
1 3
0 5
0 4
0 3
5 5
1 5
0 2
1 5
2 5
0 5
0 3
2 3
3 4
4 4
2 3
2 5
0 1
4 5...

output:

282532939566

result:

ok single line: '282532939566'

Test #12:

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

input:

3000 7 1
2 6
1 6
1 2
5 6
1 4
2 6
2 6
1 1
2 6
2 4
1 3
1 3
2 6
0 6
3 4
1 2
1 3
0 5
0 0
0 0
0 3
3 6
0 4
4 6
1 1
0 0
2 4
0 5
3 6
2 4
2 4
1 4
2 5
4 5
2 4
2 5
0 6
2 6
4 5
2 3
0 5
4 4
3 6
1 6
5 5
1 6
2 4
2 4
0 6
1 6
3 4
0 5
2 6
0 6
1 6
2 4
0 0
0 4
2 5
5 6
4 5
4 5
0 1
3 6
1 6
0 6
0 5
4 5
1 2
0 3
1 2
0 6
2 5...

output:

71432089700

result:

ok single line: '71432089700'

Test #13:

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

input:

3000 8 1
3 5
2 4
1 7
3 3
0 4
3 4
2 4
1 3
4 5
0 0
1 4
2 2
2 6
1 7
1 7
0 7
0 2
0 6
1 7
4 6
0 2
0 7
0 2
6 7
0 7
1 5
1 7
0 6
0 7
4 7
0 7
5 6
1 7
1 2
1 3
2 6
0 3
1 5
2 7
1 7
2 3
0 7
2 5
3 7
2 7
7 7
2 5
2 4
0 6
1 5
0 1
0 5
0 7
6 6
1 4
3 6
0 6
3 4
1 5
6 7
0 7
1 5
4 7
1 3
7 7
1 7
0 4
1 7
1 7
1 5
3 7
0 7
1 7...

output:

89022157300

result:

ok single line: '89022157300'

Test #14:

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

input:

3000 9 1
1 8
0 3
1 7
3 7
2 7
0 8
1 8
3 8
0 8
2 3
2 7
1 7
0 5
0 8
3 7
1 5
0 8
4 4
1 7
6 6
5 6
3 4
1 4
1 7
0 8
0 6
5 8
0 0
0 7
1 3
1 7
2 5
1 4
1 7
4 7
0 8
0 8
1 8
0 7
4 8
3 8
0 8
0 8
0 6
0 8
2 3
2 8
2 7
2 7
0 8
2 3
0 3
3 7
2 5
0 8
1 4
1 4
2 6
3 6
3 6
6 8
2 7
3 8
1 3
0 8
2 6
3 7
2 6
0 4
1 8
4 8
0 6
1 8...

output:

379045773469

result:

ok single line: '379045773469'

Test #15:

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

input:

3000 10 1
3 6
6 9
3 9
0 8
0 4
0 8
4 9
4 5
0 4
6 6
0 8
2 6
4 7
0 6
0 8
4 4
3 8
0 4
9 9
5 9
0 8
1 4
0 3
0 8
3 5
0 4
3 9
4 7
0 9
0 8
1 3
2 4
0 7
4 5
0 6
7 8
0 4
9 9
0 8
1 6
5 5
3 9
1 8
1 8
0 2
2 2
3 9
2 3
4 4
1 7
3 7
2 3
2 9
6 9
1 4
1 7
1 2
6 6
4 5
2 7
4 9
4 6
2 6
1 5
7 8
1 4
3 7
6 6
4 9
9 9
3 7
1 2
0 ...

output:

331629106039

result:

ok single line: '331629106039'

Test #16:

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

input:

3000 2934 1
1970 2832
110 2030
61 2595
313 2018
546 1871
1131 2583
216 2779
909 1996
864 1914
1011 1315
1365 2599
508 1996
955 2087
310 1272
1955 2337
781 1719
155 815
837 1681
25 2913
841 1953
376 2752
388 1124
1099 2382
1323 2198
851 2217
1459 2721
465 2160
312 2250
55 1080
180 339
764 2865
82 253...

output:

2426370144

result:

ok single line: '2426370144'

Test #17:

score: 0
Accepted
time: 3ms
memory: 4008kb

input:

2942 3000 1
425 2447
791 893
243 2737
447 1479
1447 2468
181 2810
1219 2995
2407 2628
296 1770
1535 1779
1338 2418
441 1346
1916 2767
740 2628
4 1462
230 2239
1755 1880
33 2815
283 2054
922 1731
1236 2809
513 2469
190 2711
1692 1850
31 2959
369 1998
246 2694
2524 2867
1076 2822
1204 2795
153 1294
28...

output:

3475348346

result:

ok single line: '3475348346'

Test #18:

score: 0
Accepted
time: 3ms
memory: 3776kb

input:

3000 3000 1
1390 1947
533 1520
288 2002
824 1075
363 2519
1187 2858
532 2977
31 2120
1 2937
1545 2305
1125 2756
835 2017
2055 2309
1621 2143
1316 1826
244 2875
1299 2494
509 2480
1384 1735
23 2976
443 752
290 993
495 2557
484 2973
718 1717
20 2576
470 1167
25 2557
157 2901
360 2798
1488 1917
719 294...

output:

1096040253

result:

ok single line: '1096040253'

Test #19:

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

input:

3000 11 1
6 10
3 10
0 6
0 10
0 8
2 10
4 10
0 7
0 3
0 10
0 7
0 1
4 10
0 2
7 10
0 10
0 10
1 10
2 10
9 10
9 10
8 10
10 10
0 2
0 5
7 10
0 1
0 2
8 10
0 10
0 10
0 10
0 6
9 10
5 10
0 7
0 10
0 2
0 7
4 10
6 10
0 3
0 1
6 10
3 10
4 10
7 10
2 10
0 9
10 10
0 2
8 10
3 10
9 10
0 9
5 10
0 5
4 10
0 6
0 10
0 10
10 10...

output:

231189542188

result:

ok single line: '231189542188'

Test #20:

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

input:

3000 12 1
1 11
0 9
3 11
0 10
0 0
1 11
0 11
0 1
0 0
0 6
4 11
2 11
0 0
8 11
2 11
0 5
0 11
0 5
0 9
0 9
3 11
10 11
0 1
6 11
0 6
6 11
0 2
0 3
11 11
6 11
3 11
7 11
5 11
5 11
0 9
6 11
0 0
0 10
0 1
0 2
2 11
6 11
0 1
1 11
10 11
3 11
0 4
7 11
0 1
0 0
0 9
5 11
5 11
8 11
0 9
0 1
6 11
1 11
9 11
9 11
0 0
7 11
0 5...

output:

149422997346

result:

ok single line: '149422997346'

Test #21:

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

input:

3000 13 1
6 12
0 1
4 12
0 2
4 12
0 12
1 12
3 12
11 12
0 11
10 12
9 12
0 6
0 4
9 12
1 12
0 11
0 12
10 12
5 12
0 8
11 12
2 12
0 12
7 12
0 10
4 12
11 12
0 8
0 12
6 12
0 2
0 6
4 12
5 12
4 12
0 7
1 12
0 2
3 12
9 12
9 12
4 12
0 12
8 12
0 4
0 7
4 12
10 12
0 1
0 2
12 12
7 12
4 12
0 5
0 3
0 9
0 1
0 11
6 12
0...

output:

193191161451

result:

ok single line: '193191161451'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3836kb

input:

3000 3000 1
0 557
0 987
0 1714
0 251
843 2999
0 1671
0 2445
910 2999
63 2999
2239 2999
0 1631
1817 2999
2745 2999
2477 2999
0 510
0 2631
0 1195
1028 2999
0 351
0 2953
2690 2999
0 703
937 2999
0 2489
2000 2999
0 2556
0 697
467 2999
255 2999
0 2438
2570 2999
777 2999
0 964
0 1963
1344 2999
0 1766
2199...

output:

210328057904

result:

ok single line: '210328057904'

Test #23:

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

input:

3000 2983 1
0 133
2599 2982
2541 2982
0 389
0 2825
0 432
561 2982
2514 2982
0 1865
0 706
720 2982
3 2982
1648 2982
0 1731
1890 2982
1570 2982
0 937
1853 2982
0 1418
687 2982
0 799
1530 2982
1446 2982
2216 2982
0 2047
0 2530
0 2971
0 1736
1767 2982
0 1447
0 47
601 2982
0 1758
84 2982
0 2756
0 2116
0 ...

output:

571590929028

result:

ok single line: '571590929028'

Test #24:

score: 0
Accepted
time: 2ms
memory: 3752kb

input:

2984 3000 1
0 1161
1028 2999
0 2476
0 2636
0 1914
0 776
0 2136
248 2999
0 48
2645 2999
0 829
2998 2999
359 2999
0 1766
0 927
2847 2999
1471 2999
0 1945
188 2999
295 2999
1426 2999
1831 2999
697 2999
1280 2999
0 1876
735 2999
0 1413
2326 2999
0 2970
537 2999
1249 2999
1147 2999
0 1827
0 943
0 213
0 1...

output:

472133773188

result:

ok single line: '472133773188'

Test #25:

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

input:

300 3000 1
2218 2999
2936 2999
2708 2999
2281 2999
0 1722
0 1888
0 1064
0 704
1925 2999
0 1753
2426 2999
0 1862
0 1830
572 2999
0 2435
798 2999
95 2999
1193 2999
507 2999
0 1299
0 2105
0 508
2672 2999
1956 2999
1742 2999
0 2278
0 118
586 2999
1966 2999
0 1101
77 2999
2768 2999
1755 2999
0 81
0 1013
...

output:

54180869583

result:

ok single line: '54180869583'

Test #26:

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

input:

102 3000 1
0 689
840 2999
1957 2999
0 1676
0 415
2411 2999
2855 2999
2582 2999
0 2096
2287 2999
1961 2999
0 1601
2643 2999
1220 2999
820 2999
0 1470
802 2999
392 2999
0 1762
1064 2999
2595 2999
0 748
1501 2999
0 991
0 617
0 1021
0 1598
1753 2999
0 717
0 2553
1705 2999
0 646
0 106
109 2999
0 2738
284...

output:

1972426860

result:

ok single line: '1972426860'

Test #27:

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

input:

30 3000 1
0 6
2934 2999
419 2999
0 2107
0 2694
0 1094
0 714
2652 2999
0 166
0 1841
0 1480
654 2999
922 2999
503 2999
0 1267
0 680
0 2078
0 815
1096 2999
417 2999
2967 2999
764 2999
0 585
0 703
0 2031
1558 2999
1048 2999
893 2999
0 551
0 2839
997165834 387960850

output:

4100852634

result:

ok single line: '4100852634'

Test #28:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

3000 3000 1
2 2888
284 2922
152 2772
112 2784
140 2943
32 2566
262 2972
67 2987
97 2809
69 2766
282 2975
411 2876
515 2970
66 2929
240 2686
357 2972
22 2884
27 2627
139 2776
108 2593
401 2822
26 2988
61 2845
154 2847
101 2961
80 2756
56 2833
15 2750
118 2661
130 2870
132 2799
369 2815
32 2570
252 27...

output:

4441208350

result:

ok single line: '4441208350'

Test #29:

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

input:

3000 2998 1
0 2979
109 2505
172 2990
313 2748
175 2591
167 2968
284 2698
24 2815
107 2604
34 2965
123 2877
25 2992
75 2989
38 2836
286 2960
308 2919
393 2797
1 2533
350 2969
442 2864
170 2994
57 2749
75 2846
235 2967
180 2712
135 2883
307 2871
34 2556
463 2873
352 2984
111 2721
191 2827
193 2953
51 ...

output:

707002430

result:

ok single line: '707002430'

Test #30:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

2983 3000 1
287 2693
86 2847
39 2840
24 2998
132 2547
70 2707
166 2884
168 2850
17 2994
18 2863
60 2490
164 2746
59 2806
0 2991
236 2799
189 2682
224 2705
55 2742
105 2848
131 2954
39 2975
51 2672
55 2970
108 2972
30 2539
24 2991
39 2863
193 2987
135 2838
0 2998
6 2827
349 2934
24 2618
51 2911
131 2...

output:

5259263969

result:

ok single line: '5259263969'

Subtask #2:

score: 22
Accepted

Dependency #1:

100%
Accepted

Test #31:

score: 22
Accepted
time: 1ms
memory: 3804kb

input:

500 1000000000 1
393977 997870502
1756198 996576675
709934 998910119
17244831 952957551
142872155 968927704
30385278 942410694
85734427 939378703
37926488 882420546
46151590 899775163
85788461 920969935
45003485 970828908
67012830 999694016
121553395 948429920
74733065 879692791
28285744 997261133
1...

output:

0

result:

ok single line: '0'

Test #32:

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

input:

500 1000000000 2
43974519 920435977
29442239 968626496
87296121 970680158
115030899 942979681
14500557 998008395
13920627 941658606
21697984 918354277
21474824 989173405
113175676 946584338
91193449 991632398
117741332 950425500
4841945 986925809
6561290 979837435
37960710 882087904
130890586 960747...

output:

0
0

result:

ok 2 lines

Test #33:

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

input:

500 1000000000 3
65079298 915492964
12721407 929152574
11143804 946828564
63005431 983190275
111727058 957719910
64261942 997647034
2661138 932263997
32904956 851658462
103914205 979192101
34972635 905701784
141650874 943277934
28280148 964799414
28578426 948254190
56473371 939768033
210584 98591566...

output:

0
0
0

result:

ok 3 lines

Test #34:

score: 0
Accepted
time: 42ms
memory: 4240kb

input:

10000 10 50
2 8
1 8
2 9
0 5
1 2
5 6
3 8
1 5
5 8
0 9
0 8
1 9
1 4
0 9
0 5
4 9
3 8
0 0
0 7
2 2
3 6
3 7
3 4
2 9
0 9
4 4
3 5
3 3
1 8
1 1
1 8
0 8
1 6
4 9
3 8
1 7
0 9
0 1
6 7
0 9
7 8
0 9
0 2
2 8
0 7
2 9
1 5
0 9
4 6
0 9
0 9
3 9
0 7
7 7
1 3
7 7
4 8
2 2
5 9
0 5
0 8
1 9
5 7
0 4
8 8
7 9
2 5
0 0
4 8
0 9
0 0
1 5
...

output:

1649863551856
1380493275351
1295735155923
456578775016
269155165802
2011614159399
1892104544432
54016244655
361549026140
2209229746705
1681910746040
2032120266616
1669809044383
109490055677
128024603685
1030140493987
1259667253169
1189990827451
715960613154
700481506423
2274746221202
785728954942
10...

result:

ok 50 lines

Test #35:

score: 0
Accepted
time: 42ms
memory: 4004kb

input:

9832 10 50
1 9
9 9
0 0
5 5
2 8
2 2
1 8
0 2
7 8
0 7
0 9
0 7
6 6
0 5
4 4
0 4
2 6
4 8
1 4
0 3
2 5
0 7
4 6
3 5
1 3
0 7
1 4
1 1
7 8
5 6
6 6
2 8
4 8
0 5
2 9
1 8
7 7
0 8
1 9
5 7
5 9
0 9
3 8
2 7
9 9
2 8
1 6
6 9
7 9
6 9
0 2
5 8
0 5
3 8
2 8
1 6
5 8
5 7
5 8
3 8
6 9
1 1
0 9
5 7
1 7
0 6
2 6
0 3
5 6
1 3
4 6
0 3
2...

output:

1378443658556
857998452840
1293813485431
297464448442
1369627125846
1359835626172
351733409760
124639699522
276857107656
1564926701148
759837697040
799056479278
1553471666256
1012477907941
583214322252
1702523008578
1847753651510
1178106858132
1449636926490
714740890115
1222083686983
1506741555570
1...

result:

ok 50 lines

Test #36:

score: 0
Accepted
time: 42ms
memory: 4240kb

input:

9992 10 50
0 9
0 3
7 9
7 8
4 4
5 9
3 9
0 2
0 9
1 3
1 9
0 8
4 5
3 7
1 9
3 7
6 8
0 2
0 6
0 9
0 7
1 9
0 5
7 8
5 5
0 9
5 5
3 7
3 7
2 6
2 9
5 6
3 4
0 2
1 8
4 9
1 1
2 8
0 9
9 9
3 8
0 9
1 6
1 8
2 3
2 5
0 9
6 7
0 9
0 9
3 6
3 8
7 9
1 4
5 6
6 8
4 5
1 8
0 7
0 1
3 6
1 1
3 8
0 8
0 7
2 9
8 8
0 0
0 9
0 8
5 8
0 8
1...

output:

1089280441974
911545129815
1702130683775
1115940623033
1342106230108
1426523140438
1874018732010
1604529541358
912762859839
109067937442
1161878443768
479354354703
819140165334
1345018325511
1810919837512
995261837949
1746870350577
1070098412673
1189911711601
1045950992563
104426725350
915145067796
...

result:

ok 50 lines

Test #37:

score: 0
Accepted
time: 42ms
memory: 4244kb

input:

9999 10 50
4 7
2 6
4 5
0 9
1 4
2 4
0 9
0 7
4 6
1 5
0 9
0 9
8 9
8 9
0 5
0 6
3 9
0 7
2 9
2 6
7 9
0 9
2 2
5 8
0 8
2 6
0 2
0 6
8 9
4 4
4 9
8 9
1 9
2 4
0 9
1 4
7 9
0 7
1 9
3 7
6 6
3 8
1 3
1 7
4 8
3 5
0 7
0 6
1 4
2 7
3 4
3 9
1 8
5 8
2 8
2 9
1 8
0 0
1 4
4 9
7 8
3 4
2 6
0 1
0 6
0 9
0 2
2 9
0 7
0 6
3 6
1 4
2...

output:

372460365620
1634853480866
1534140352302
718715629680
653936073847
1067842822709
1201573952498
977635699337
734238002896
1339793613482
1125877285656
1283444333017
996916544582
1561246431605
803486020256
139011978878
673971207401
1509662033195
525585080257
415638787089
1426288117953
862849828731
2094...

result:

ok 50 lines

Test #38:

score: 0
Accepted
time: 42ms
memory: 4076kb

input:

9998 10 50
0 9
1 4
3 3
0 9
0 0
0 7
0 4
1 2
1 4
7 8
1 7
7 9
4 8
5 5
0 9
0 7
0 9
0 7
0 9
5 8
1 8
0 0
0 9
4 9
0 8
8 9
1 7
0 9
0 4
3 9
8 8
0 8
0 9
3 6
3 7
2 9
1 7
1 8
0 5
1 9
0 9
0 6
3 9
1 5
2 9
8 8
1 9
0 8
4 5
2 4
6 6
1 3
1 3
2 8
1 7
4 9
4 7
1 7
4 9
1 1
0 9
2 3
0 4
1 7
5 9
2 3
2 7
7 8
0 8
0 6
2 8
1 9
2...

output:

611793093574
201685481368
1533925723413
1408214159533
238932242048
1308985387347
1734620358003
1552465238864
903779848850
1072305049224
1454494793160
957522918654
971211575890
504161374622
866615656278
1325484652214
1451397721420
1166045811382
1475933374056
1264350326666
1245391231143
381039251337
1...

result:

ok 50 lines

Test #39:

score: 0
Accepted
time: 242ms
memory: 8736kb

input:

10000 10000000 50
729335 4474024
2957651 9671040
157805 8785447
4978104 6804574
590354 9013150
9105286 9773295
275620 8989970
988506 9552369
708053 9480272
1145367 9928445
4220566 8196666
2384122 8714777
4960256 5679148
1485223 8722760
8423474 9065820
2906359 7574355
611496 3791794
2390688 7399287
4...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #40:

score: 0
Accepted
time: 248ms
memory: 8908kb

input:

10000 100000000 50
26094129 46340947
1574912 16411111
1244864 99007950
4999658 93469414
29962241 93953822
60323383 82671714
31698933 48162468
7452043 76197971
1366564 98068302
47521153 91200490
23949140 50203595
35796993 83104108
80490350 96374769
9780735 34919531
21917325 64524877
29252551 92783766...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #41:

score: 0
Accepted
time: 247ms
memory: 8736kb

input:

10000 1000000000 50
83505471 923074158
94613918 405598288
665314527 912442561
771505210 889921062
273417690 713102463
13566476 60637129
251456335 863585923
711676585 932718005
39044158 759649917
424395361 473265492
363923063 870226530
451469216 570185953
44707425 993383091
352091155 491593483
491882...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #42:

score: 0
Accepted
time: 145ms
memory: 6552kb

input:

10000 1000000000 50
0 839568687
0 310984370
752871965 999999999
0 118415852
560315226 999999999
952929346 999999999
387870411 999999999
778958579 999999999
279394240 999999999
951129868 999999999
493696532 999999999
0 118716737
51324333 999999999
860497671 999999999
0 875449854
24976687 999999999
0 ...

output:

696597739794
266176557990
1970879196178
684774019800
2233676554772
85570134438
82479242088
1315310038194
1964127560535
1303124333670
2004138755004
1723614092004
657237350202
1046519079678
672265278618
1869013917384
1867639019058
2155918088500
1123045283646
1127766644869
723519514644
2173936687999
97...

result:

ok 50 lines

Test #43:

score: 0
Accepted
time: 134ms
memory: 6420kb

input:

9982 1000000000 50
751253804 999999999
41448819 999999999
0 486617498
581188549 999999999
207467831 999999999
523117450 999999999
0 817770806
0 143742207
739618766 999999999
0 756013904
903136263 999999999
257240814 999999999
0 716550721
0 692565666
0 223939252
231223402 999999999
0 36957039
4961044...

output:

243822165972
192680300346
167236970108
1495872659268
1076907661333
66006732589
332531219521
901775092456
1901056821123
1312580043107
1690158339732
1592975825443
351975246624
901618638605
405597343062
508734881664
2204707960170
1814047107957
919043545410
2354932642702
326116417410
1727382613715
98775...

result:

ok 50 lines

Test #44:

score: 0
Accepted
time: 126ms
memory: 6404kb

input:

9999 1000000000 50
0 615011321
203682777 999999999
0 605855898
404418706 999999999
0 496000807
0 772879546
0 48301746
749498965 999999999
496088573 999999999
0 42493134
135123950 999999999
103010261 999999999
913018226 999999999
14661193 999999999
0 634010203
435875870 999999999
0 241239056
66047435...

output:

1419808098675
1531112576190
147844971724
1318846684903
730252389030
1654321368420
503628558714
473991987411
2271234707413
268666306363
447850314084
1887231992396
1700702357302
1399415739636
1344157229385
2468804068416
1681561884330
96786084190
1475315789281
2007780896292
1230978650847
955754347176
1...

result:

ok 50 lines

Test #45:

score: 0
Accepted
time: 121ms
memory: 6240kb

input:

9299 1000000000 50
0 362466509
0 820187946
0 680484189
0 972566948
896391507 999999999
857624048 999999999
0 443769629
800085025 999999999
0 920664663
0 125671948
193579065 999999999
0 501147542
763917542 999999999
0 941669372
0 271777474
0 959354820
0 257577081
30472 999999999
0 699016633
0 3165664...

output:

288947004411
1327912461580
1946571078708
344708175375
1643544301031
103358521350
1075366115617
1422239164944
418968049200
323518701180
786799349655
1503443288368
771548622840
1689502072624
997889742747
733836359086
582495305490
62512939830
311023111222
1536939048823
160139796180
1415138024047
190303...

result:

ok 50 lines

Test #46:

score: 0
Accepted
time: 133ms
memory: 6616kb

input:

9988 1000000000 50
231916624 999999999
600745774 999999999
0 91988648
394579495 999999999
290230212 999999999
0 22106867
351710268 999999999
0 726638490
0 60577904
0 4995157
34636344 999999999
110436028 999999999
92918241 999999999
0 433329812
905701598 999999999
0 14041871
0 95513168
0 903615629
84...

output:

34550042550
2378684731136
263201879257
2226856881035
2101753408158
674280265626
1031189125738
813990978584
1328647182498
1568997798278
2015203363002
487031008493
1088284478481
1333457775191
336005122710
882888660812
1648114012844
219614239219
1529690665072
496390167854
382253688756
1123278792750
185...

result:

ok 50 lines

Test #47:

score: 0
Accepted
time: 37ms
memory: 4124kb

input:

9899 100 50
0 0
2 99
0 1
3 99
0 1
3 99
0 2
4 99
0 2
4 99
0 2
4 99
0 3
5 99
0 3
5 99
0 3
5 99
0 3
5 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 7
9 99
0 7
9 99
0 7
9 99
0 7
9 99
...

output:

62878964940
2507979474
31942553346
51691508649
87170681229
7934649624
50542576800
27577432080
18677957661
81817770051
81760342240
49699624392
23006652867
86364975246
18489902706
96012691134
67884094470
15705990630
87826963710
21510918
79896841977
48792190788
21052115172
31313019177
39056329521
95932...

result:

ok 50 lines

Test #48:

score: 0
Accepted
time: 158ms
memory: 8632kb

input:

10000 1000000000 50
434537485 434537488
577666052 577666060
138646722 138646729
705400356 705400364
252323954 252323954
224665599 224665600
529051370 529051371
981252995 981252997
319882598 319882604
186765603 186765607
548574454 548574463
1939299 1939304
698514047 698514048
141026871 141026873
5997...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #49:

score: 0
Accepted
time: 162ms
memory: 8628kb

input:

9981 1000000000 50
265936628 265936629
947025622 947025622
167361603 167361608
34819891 34819892
50238 50239
900316161 900316169
408550752 408550753
247515328 247515335
839276183 839276187
235391238 235391240
993089859 993089865
777785644 777785645
544237624 544237627
507917860 507917867
525268013 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #50:

score: 0
Accepted
time: 160ms
memory: 8620kb

input:

9999 1000000000 50
95394888 95394894
157356524 157356526
485447725 485447731
109320283 109320284
305412192 305412193
419474134 419474142
966497349 966497351
223859236 223859237
472738680 472738687
601927366 601927374
434676915 434676923
986754841 986754841
633154676 633154683
295631212 295631214
958...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #51:

score: 0
Accepted
time: 244ms
memory: 8884kb

input:

9919 1000000000 50
19089751 927973844
166201886 979163287
13706533 916676558
7251956 968383703
108783573 966366124
19165667 987857830
131407491 959683656
106434524 961651431
85009751 942548499
171066355 997578293
61369650 950508202
57704056 917089925
12512032 986652828
74619355 997994073
3015812 862...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #52:

score: 0
Accepted
time: 245ms
memory: 8712kb

input:

9999 1000000000 50
139844846 956026262
39645451 964617380
70102940 881088032
66950387 920613183
36168383 992729116
1172960 849880575
138689558 954556608
69245243 965672286
6772663 998548601
101823643 927399142
122314975 995919253
60385421 976750335
115246777 922375449
52932505 963335081
21107662 974...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #53:

score: 0
Accepted
time: 242ms
memory: 8920kb

input:

10000 1000000000 50
26019963 986004340
135956798 957041333
74345129 995390966
37470406 971633583
6982380 993497461
1852003 997425537
99501335 916902303
29793505 986476975
24134905 967445231
99775489 900900089
3518147 985365032
9079269 987999474
38712805 953541421
83415077 903618507
16520068 97229329...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #54:

score: 0
Accepted
time: 3ms
memory: 4520kb

input:

2500 1000000000 1
69982162 897481319
93909340 971225230
25403663 975432851
100160250 998303574
18288063 978337446
14690266 834474105
43321029 879707967
2806602 997653166
10998013 834998586
102082843 993472093
37312722 933171618
11042631 973010690
75238889 951604400
102950908 963375635
8002067 974389...

output:

0

result:

ok single line: '0'

Test #55:

score: 0
Accepted
time: 4ms
memory: 5060kb

input:

2500 1000000000 2
19605569 821056934
89607328 944170128
14522742 816852653
70567745 965979856
31379062 948880734
6575748 842072150
17103567 991469798
140107124 953125484
134950990 948802102
16471509 973118234
17622476 882424264
5964544 912302554
31392683 949125088
96597266 996189461
8932118 93116813...

output:

0
0

result:

ok 2 lines

Test #56:

score: 0
Accepted
time: 5ms
memory: 5060kb

input:

2500 1000000000 3
84154405 964590704
66328987 898138697
120110443 974741077
8252696 857985014
3149958 888169369
36113055 982289296
14005934 831384181
12418677 981524689
3789749 859510096
6808412 933745337
3459770 975120304
31692998 987433685
2563015 961662314
44318376 878045313
69189074 990222156
30...

output:

0
0
0

result:

ok 3 lines

Test #57:

score: 0
Accepted
time: 7ms
memory: 8576kb

input:

10000 1000000000 1
1597835 938710770
7738329 968351075
1024579 996355922
65986890 985203652
36276572 853398191
53884887 998039748
15645551 864773094
3631503 987092655
79007028 923707505
70809091 952073788
35073593 998719021
88380495 999528022
43595074 983501918
4676285 978072562
43927362 899758425
8...

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 10ms
memory: 8816kb

input:

10000 1000000000 2
84236720 900334588
11067358 948927014
39708320 930288966
12622012 981126256
22493600 997067508
38050988 987852961
7635337 994742172
69028476 903544553
5655450 997257888
90108454 941663351
121674144 992178318
37810329 998360533
16867036 903173499
50371937 862935681
11116397 8328613...

output:

0
0

result:

ok 2 lines

Test #59:

score: 0
Accepted
time: 21ms
memory: 8752kb

input:

10000 1000000000 3
61100708 946118059
134139824 954279114
104328520 942177163
555004 966328036
18894910 855953832
20894098 881375909
19898971 882900952
2970559 993574288
26042607 997430133
54784827 971597200
141608174 981055239
159767488 969720368
6375646 996133149
79273530 931004742
22101799 937611...

output:

0
0
0

result:

ok 3 lines

Subtask #3:

score: 0
Time Limit Exceeded

Test #60:

score: 0
Time Limit Exceeded

input:

500 10 1000000
2 9
2 7
3 6
1 6
3 5
0 5
3 4
6 8
4 8
1 6
1 5
6 7
7 7
6 9
0 7
4 5
0 6
0 2
4 6
0 6
1 7
2 8
0 9
0 9
0 9
0 7
3 6
8 8
2 4
4 4
0 5
2 5
1 6
0 9
2 7
0 8
9 9
1 4
0 9
2 4
1 9
2 8
2 6
0 4
5 9
4 5
3 9
2 6
1 9
0 6
6 8
2 9
4 9
7 9
2 7
1 5
1 8
0 6
0 9
2 9
3 9
0 2
4 4
5 9
4 7
8 9
4 9
1 8
3 8
2 9
6 6
3...

output:

109125435050
79679504214
40397444309
33486843995
50549382350
8831039674
29373662236
35916635082
1627822212
83193326242
7021463069
18347246004
17908310304
40111838606
42807634739
83808922569
36682521996
87471336298
56912099994
74488880562
59044328919
71779759293
47086282044
46402519236
10235901992
55...

result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%