QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443301#8648. Towerarbuzick#5 48ms18032kbC++201.6kb2024-06-15 15:05:562024-06-15 15:05:57

Judging History

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

  • [2024-06-15 15:05:57]
  • 评测
  • 测评结果:5
  • 用时:48ms
  • 内存:18032kb
  • [2024-06-15 15:05:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

constexpr long long inf = (long long)1e18 + 7;

constexpr int maxval = 1e6 + 5;

long long dp[maxval];

int dp2[maxval];

void solve() {
    int n, q;
    cin >> n >> q;
    long long d;
    int a, b;
    cin >> d >> a >> b;
    for (int i = 0; i < maxval; ++i) {
        dp[i] = inf;
    }
    vector<pair<long long, long long>> lr(n);
    for (int i = 0; i < n; ++i) {
        cin >> lr[i].first >> lr[i].second;
        lr[i].second++;
        for (int j = lr[i].first; j < lr[i].second; ++j) {
            dp[j] = inf * 2;
        }
    }
    dp[0] = 0;
    dp2[0] = 0;
    for (int i = 0; i < maxval; ++i) {
        if (dp[i] != -1) {
            if (i + 1 < maxval && dp[i + 1] != inf * 2) {
                dp[i + 1] = min(dp[i + 1], dp[i] + a);
                dp2[i + 1] = max(dp2[i + 1], dp2[i]);
            }
            if (i + d < maxval && dp[i + d] != inf * 2) {
                dp[i + d] = min(dp[i + d], dp[i] + b);
                dp2[i + d] = max(dp2[i + d], dp2[i] + 1);
            }
        }
    }
    for (int i = 0; i + 1 < maxval; ++i) {
        if (dp[i] < inf && dp[i + 1] < inf) {
            assert(dp2[i] + 1 >= dp2[i + 1]);
        }
    }
    while (q--) {
        long long x;
        cin >> x;
        if (dp[x] >= inf) {
            cout << -1 << '\n';
        } else {
            cout << dp[x] << '\n';
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 31ms
memory: 15312kb

input:

2000 200000
500 66309 387245
91 122
793 1029
1127 1131
1304 1611
2007 2039
2601 2701
2906 3052
3253 3263
3495 3609
4157 4225
4283 4283
4757 4766
4786 4847
4885 5086
5326 5342
5607 5750
5847 5877
6093 6230
6548 6793
7206 7308
7413 7419
7752 7780
8244 8410
8501 8515
9335 9447
9512 9514
9602 9906
10076...

output:

-1
-1
1545376776
-1
1355518146
-1
-1
1538578776
1124179254
736677313
275840218
-1
314646902
120181124
592802647
1470145222
1194355416
630012616
541479470
1380556431
748297307
1579324340
83071935
-1
547672724
766967273
940718126
967114418
448357717
-1
208077708
264694996
68332763
-1
699361243
1542138...

result:

ok 200000 lines

Test #2:

score: 0
Accepted
time: 27ms
memory: 15372kb

input:

2000 200000
500 45649 229891
123 232
663 994
1023 1041
1065 1065
1523 1542
1962 1983
2044 2066
2449 2453
2589 2591
2788 2810
3207 3418
3666 3685
3944 3945
4256 4320
4699 4706
4915 4950
5196 5207
5271 5545
5705 5707
5867 6034
6273 6328
6364 6380
6764 6787
6974 7007
7363 7365
7632 7648
7754 7924
7954 ...

output:

-1
-1
1044862158
349767467
-1
-1
-1
-1
534260754
853076992
514160380
514034955
-1
-1
680989150
557376047
-1
410302211
-1
-1
14156128
-1
-1
656642980
-1
335413929
465525211
1047741337
1007928386
-1
183280077
-1
842399625
553981561
-1
-1
486838795
823208939
597570650
68518820
-1
-1
36379839
-1
4959492...

result:

ok 200000 lines

Test #3:

score: 0
Accepted
time: 30ms
memory: 15532kb

input:

2000 200000
500 11 228852
288 470
648 922
1193 1288
1509 1516
1792 1915
2023 2061
2443 2477
2512 2693
2735 2860
3176 3196
3260 3363
3622 3658
3939 3988
4177 4223
4470 4541
4640 4789
4812 4850
5167 5246
5443 5594
5692 5804
5875 5982
6265 6286
6416 6609
6816 6833
6928 7130
7298 7305
7401 7403
7778 781...

output:

61754766
1843455
193255572
95486804
80338946
188441144
126474653
-1
119132183
159054071
107422913
158596895
105813337
-1
166163718
-1
165014783
-1
2988793
146889891
-1
75748618
-1
-1
-1
109483978
-1
112469548
163413919
67263527
170983140
128997679
168000122
-1
186380233
151702042
42025050
-1
1556077...

result:

ok 200000 lines

Test #4:

score: 0
Accepted
time: 26ms
memory: 15316kb

input:

2000 200000
500 123 507044
13 349
778 805
1289 1419
2069 2074
2126 2129
2299 2392
2629 2629
3035 3054
3171 3184
3225 3381
3967 4100
4222 4225
4432 4603
4741 4745
4972 5123
5239 5245
5412 5530
5737 5757
5859 6162
6286 6289
6452 6542
6820 6825
6940 6974
7327 7328
7686 7781
8122 8169
8499 8909
8957 896...

output:

23238378
-1
320316781
492915201
-1
118374346
-1
118865646
-1
27397189
413766267
33059543
89523552
84434908
75590808
178982529
452655813
119364449
76127495
-1
-1
296028030
320308540
475355659
-1
210903877
288320772
388500820
-1
149739573
428228318
-1
-1
-1
-1
478454749
-1
-1
-1
-1
268399317
-1
310981...

result:

ok 200000 lines

Test #5:

score: 0
Accepted
time: 29ms
memory: 15572kb

input:

2000 200000
500 367 183500
395 476
616 705
1068 1085
1392 1462
1898 2004
2105 2124
2266 2553
2678 2684
2845 2855
3145 3188
3497 3630
3705 3708
3857 3995
4221 4223
4405 4642
4724 4730
4993 5199
5224 5225
5325 5637
5722 5735
6111 6152
6322 6341
6464 6694
6764 6838
7013 7174
7249 7261
7423 7713
7803 78...

output:

-1
81789987
195275562
134586974
172718274
-1
77090919
-1
169680615
26763842
81273618
74582841
-1
-1
164912918
-1
45100263
25295842
5720062
138829861
-1
23310005
142354162
158449681
-1
43546018
5823556
-1
-1
-1
-1
125462620
-1
25779548
121436630
4706408
-1
-1
-1
87290583
-1
47107386
94590213
17249256...

result:

ok 200000 lines

Test #6:

score: 0
Accepted
time: 48ms
memory: 17828kb

input:

195716 197150
20 41515 610194
34 34
36 36
38 38
40 40
42 42
44 44
46 46
83 83
85 85
87 87
89 89
91 91
93 93
95 95
97 97
99 99
104 104
106 106
108 108
110 110
112 112
114 115
118 118
120 120
132 132
134 134
136 136
138 138
140 140
142 142
144 144
146 146
148 148
150 150
175 175
177 177
179 179
181 18...

output:

27145048833
-1
20311977145
5823894704
12611222982
10375331362
-1
4666825214
8294213599
7946746140
15043381651
12084461892
2564209663
-1
2889605968
30371230407
13809822492
10059353510
20452787039
-1
186985672
-1
-1
-1
14667164575
21798169916
2551478619
-1
2357959404
24230797781
5359696913
11480637002...

result:

ok 197150 lines

Test #7:

score: 0
Accepted
time: 44ms
memory: 17948kb

input:

194401 196154
20 81884 184176
27 27
29 29
31 31
33 33
35 35
37 37
39 39
41 41
43 43
45 45
103 106
110 110
114 115
119 119
121 121
123 123
125 126
128 128
130 130
132 132
135 135
137 137
170 171
173 173
175 175
179 179
181 181
183 184
186 186
203 203
205 205
207 207
210 210
212 212
214 214
216 216
22...

output:

-1
7397081928
2079536780
1740817712
7985105512
8791917840
-1
2108310564
3818312684
3403790452
-1
-1
7282843676
8094061364
8075949632
-1
4202973208
-1
5158569260
5191129360
-1
5769244224
-1
5536679820
7825620684
4417835300
10616377912
-1
7443886064
5554791552
7631714344
4169124128
10019841164
8876887...

result:

ok 196154 lines

Test #8:

score: 0
Accepted
time: 44ms
memory: 18032kb

input:

197806 197356
20 29644 637771
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17
19 19
21 21
71 71
73 73
75 75
77 77
79 79
81 81
83 83
85 85
87 87
89 89
94 94
96 96
98 98
100 100
102 102
104 104
106 107
122 122
124 124
126 126
128 128
131 131
133 133
135 135
156 156
158 158
160 160
163 163
165 165
216 216
218 ...

output:

-1
16958900222
16962903862
-1
-1
30908851790
986967014
7741518462
14743639172
1812847470
-1
7369833863
26993152521
2971365427
-1
-1
-1
-1
26587991346
16925804768
2134704702
17196127075
-1
26659445339
29693622258
812738814
25306954578
27428620967
29707753999
13380005667
1927010073
9821528975
-1
86888...

result:

ok 197356 lines

Test #9:

score: 0
Accepted
time: 44ms
memory: 17900kb

input:

199268 195219
20 9959 224682
19 21
23 23
26 27
29 31
33 33
35 35
37 37
57 57
59 59
61 61
63 63
65 65
67 67
69 69
71 71
73 73
127 129
131 134
136 138
153 153
155 155
157 157
159 159
161 161
163 163
166 166
196 196
198 198
200 200
202 202
204 204
206 206
208 208
210 210
212 212
214 214
224 224
226 226...

output:

1405185734
2296959792
-1
4763754065
-1
7440241155
3592032994
9232017710
-1
2996088597
7328570009
8931662575
7527861716
8627630151
4396636490
4153239129
4674940842
7142306979
5741444947
-1
-1
203363729
5005824000
-1
5999988912
-1
10315869532
2347062895
-1
499028001
-1
6310540106
6132479839
6198718827...

result:

ok 195219 lines

Test #10:

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

input:

194139 191791
20 37198 743960
1 1
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17
19 19
28 28
30 30
32 32
34 34
36 36
39 39
41 41
43 43
45 45
79 79
81 81
83 83
85 85
87 87
89 89
91 91
97 97
103 103
105 105
107 107
109 109
111 111
113 114
116 116
118 119
121 121
124 124
126 126
128 128
130 130
132 132
134 13...

output:

5683965994
30465347990
13469395800
-1
24426289888
-1
3251625972
32267925872
-1
28405583136
32475193128
-1
10144378174
29396203074
33933652312
20332203612
-1
-1
2572204502
10948710528
24839410876
15655745448
4906750982
18881853592
11878734924
10340783614
3981301940
15892771104
36311460066
7953527568
...

result:

ok 191791 lines

Test #11:

score: 0
Accepted
time: 47ms
memory: 17852kb

input:

200000 200000
1 58118 14529
100001 100001
100006 100006
100008 100008
100010 100010
100013 100013
100019 100019
100023 100023
100026 100026
100028 100028
100032 100032
100035 100035
100042 100042
100045 100045
100048 100048
100051 100051
100053 100053
100057 100057
100064 100064
100068 100068
100071...

output:

11521497
3864714
10184829
2411814
-1
13192332
3138264
-1
-1
11913780
13846137
10097655
-1
624747
-1
10620699
-1
9066096
4663809
377754
-1
5680839
842682
-1
-1
6508992
1612719
12974397
-1
7380732
-1
-1
-1
363225
-1
7235442
813333420
-1
1670835
-1
4925331
11187330
10315590
-1
-1
1336668
-1
-1
-1
11579...

result:

ok 200000 lines

Test #12:

score: 0
Accepted
time: 44ms
memory: 17912kb

input:

200000 200000
2 301112 823921
13 13
16 16
18 18
20 20
23 23
27 27
31 31
34 34
37 37
43 43
47 47
54 54
56 56
61 61
65 65
69 69
73 73
76 76
83 83
87 87
93 93
101 101
105 105
108 108
114 114
117 117
125 125
129 129
131 131
136 136
141 141
146 146
154 154
159 159
162 162
172 172
181 181
183 183
187 187
...

output:

-1
-1
-1
-1
266027349
237726146
13850227972
159857299
-1
185465042
-1
48505478
-1
-1
105567826
284884894
-1
-1
223004754
-1
-1
254237662
-1
-1
-1
333754351
320919046
-1
-1
-1
103539457
-1
-1
111732348
-1
-1
-1
-1
125613271
-1
7624151759
-1
89420289
-1
28681730
-1
-1
23663241042
-1
-1
-1
-1
174055882...

result:

ok 200000 lines

Test #13:

score: 0
Accepted
time: 45ms
memory: 17924kb

input:

200000 200000
3 29787 89361
4 4
8 9
13 13
17 18
20 21
23 23
28 28
33 33
35 36
38 39
44 44
48 49
56 57
59 60
62 62
65 65
67 68
75 75
83 83
92 93
99 100
106 107
109 109
112 112
116 117
119 119
128 128
131 131
137 137
140 140
142 143
146 146
153 153
155 155
162 162
165 166
170 170
172 172
177 177
182 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1727646
-1
774462
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
446805
-1
-1
-1
-1
-1
-1
-1
148935
-...

result:

ok 200000 lines

Test #14:

score: 0
Accepted
time: 45ms
memory: 17884kb

input:

200000 200000
100000 1 167528
29806 29806
29808 29809
29812 29812
29814 29814
29816 29816
29822 29822
29825 29827
29829 29833
29835 29835
29847 29848
29852 29853
29856 29857
29859 29860
29864 29864
29867 29867
29870 29870
29872 29875
29879 29879
29882 29883
29885 29885
29891 29891
29893 29901
29903 ...

output:

-1
1006360
1440905
385
-1
352
509
655939
818
616
192147
14845
-1
619
-1
1293669
719
889
173180
777
949
261
209851
419
387955
1280628
417
868984
-1
809
-1
56
-1
1451072
-1
572
505
218
419794
1081185
815543
-1
663
-1
583
-1
408164
191620
393843
889671
896314
171
95
827257
1255818
779
82
-1
-1
280
7792...

result:

ok 200000 lines

Test #15:

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

input:

200000 200000
1000000 1860 149443
100003 100003
100005 100005
100007 100008
100010 100013
100018 100019
100021 100022
100024 100026
100029 100031
100033 100033
100035 100040
100045 100045
100048 100048
100050 100050
100052 100053
100055 100058
100060 100060
100064 100065
100067 100068
100070 100070
...

output:

1244340
-1
-1
-1
783060
-1
-1
1757700
-1
-1
1523340
851880
61275840
-1
390600
-1
1716780
846300
1002540
1575420
-1
72540
-1
-1
466860
-1
-1
598920
1275960
-1
1088100
137911560
123182220
1192260
-1
998820
624960
673320
-1
1752120
-1
120900
1791180
1075080
-1
1655400
130200
1091820
-1
-1
1097400
-1
-1...

result:

ok 200000 lines

Test #16:

score: 0
Accepted
time: 46ms
memory: 17840kb

input:

200000 200000
1000000000000 75183 634442
100000 100002
100004 100006
100011 100011
100013 100016
100020 100021
100023 100026
100028 100030
100034 100034
100039 100041
100044 100045
100048 100051
100056 100058
100060 100060
100063 100064
100066 100068
100071 100072
100076 100079
100081 100082
100085 ...

output:

-1
-1
-1
62777805
-1
6156510321
6691287
-1
-1
38192964
56687982
68717262
21803070
-1
-1
70145739
11803731
-1
20073861
-1
-1
5868559431
-1
27667344
-1
-1
16465077
-1
-1
-1
71499033
65709942
61800426
-1
-1
51274806
-1
-1
2510811468
-1
-1
56838348
8420496
12330012
-1
65334027
-1
-1
67138419
-1
-1
72100...

result:

ok 200000 lines

Test #17:

score: 0
Accepted
time: 19ms
memory: 15300kb

input:

1 200000
1 1 1
999999 999999
999995
334480
887900
420867
999997
878684
1000000
876358
618747
239631
999996
1000000
780417
875263
688426
700188
2
999996
494065
575102
601330
999993
209409
796732
580329
463096
862473
536243
716601
999992
307942
868274
999996
662241
390192
6
746933
999990
3
751307
8247...

output:

999995
334480
887900
420867
999997
878684
-1
876358
618747
239631
999996
-1
780417
875263
688426
700188
2
999996
494065
575102
601330
999993
209409
796732
580329
463096
862473
536243
716601
999992
307942
868274
999996
662241
390192
6
746933
999990
3
751307
824702
-1
224547
999995
416477
-1
944107
9
...

result:

ok 200000 lines

Test #18:

score: 0
Accepted
time: 27ms
memory: 15348kb

input:

1 200000
1 1000000 1
999999 999999
261223
999990
660671
999991
686540
999995
481082
6
9
210190
975680
999996
999995
999997
10
494817
999990
999998
893404
999998
289929
999991
197231
999996
22235
2
835177
999998
4
801369
520076
1000000
279802
10
287199
216013
647644
625195
999994
454938
155991
282147...

output:

261223
999990
660671
999991
686540
999995
481082
6
9
210190
975680
999996
999995
999997
10
494817
999990
999998
893404
999998
289929
999991
197231
999996
22235
2
835177
999998
4
801369
520076
-1
279802
10
287199
216013
647644
625195
999994
454938
155991
282147
152171
839255
885000
973358
940109
4748...

result:

ok 200000 lines

Test #19:

score: 0
Accepted
time: 29ms
memory: 15340kb

input:

1 200000
1 1 1000000
999999 999999
922791
999998
777168
997973
999999
999990
5
999994
549792
7
994306
999996
277953
686651
2
2
999995
6
50142
4
66529
7
463529
999990
10
528627
765208
266964
8
92765
999991
999994
103982
703958
999990
994373
999992
695826
168004
463044
999998
3
385692
486278
564796
1
...

output:

922791
999998
777168
997973
-1
999990
5
999994
549792
7
994306
999996
277953
686651
2
2
999995
6
50142
4
66529
7
463529
999990
10
528627
765208
266964
8
92765
999991
999994
103982
703958
999990
994373
999992
695826
168004
463044
999998
3
385692
486278
564796
1
2
6
209259
436231
938452
4
5
999990
7
8...

result:

ok 200000 lines

Test #20:

score: 0
Accepted
time: 29ms
memory: 15344kb

input:

1 200000
1 1000000 1000000
999999 999999
480704
4610
969413
5
999990
6
999997
120849
4
999992
526100
916996
7
42823
7
994464
899291
125047
446789
308053
545643
379966
1
7
748119
944339
8
999990
3
777027
999994
999990
999990
999996
999998
762900
452898
858332
986471
1
3
448913
999995
7
999993
992420
...

output:

480704000000
4610000000
969413000000
5000000
999990000000
6000000
999997000000
120849000000
4000000
999992000000
526100000000
916996000000
7000000
42823000000
7000000
994464000000
899291000000
125047000000
446789000000
308053000000
545643000000
379966000000
1000000
7000000
748119000000
944339000000
...

result:

ok 200000 lines

Test #21:

score: 0
Accepted
time: 22ms
memory: 15344kb

input:

1 200000
1000000 1 1
999999 999999
4
399947
736915
1
447669
1000000
259362
52351
6
813992
147272
863459
999992
7
999997
1
809636
999999
9
986388
999993
430094
2
782151
607157
45682
167704
765797
408410
999996
783731
540374
8
6
4
1000000
4
999995
8
512519
320711
999992
228605
999995
745015
8
4
521329...

output:

4
399947
736915
1
447669
1
259362
52351
6
813992
147272
863459
999992
7
999997
1
809636
-1
9
986388
999993
430094
2
782151
607157
45682
167704
765797
408410
999996
783731
540374
8
6
4
1
4
999995
8
512519
320711
999992
228605
999995
745015
8
4
521329
7
129519
964131
187402
112914
9
480716
665911
9395...

result:

ok 200000 lines

Test #22:

score: 0
Accepted
time: 16ms
memory: 15336kb

input:

1 200000
1000000 1000000 1
999999 999999
5
201390
999992
752699
10
5
1000000
455223
694001
999996
999997
999997
914856
702530
272565
4
458638
999997
799551
7
999990
7
218054
2
250231
999997
1
138997
10
693753
4
275706
623774
10
321139
8
26866
121967
5
999993
315765
228884
311503
251989
3
737033
5315...

output:

5000000
201390000000
999992000000
752699000000
10000000
5000000
1
455223000000
694001000000
999996000000
999997000000
999997000000
914856000000
702530000000
272565000000
4000000
458638000000
999997000000
799551000000
7000000
999990000000
7000000
218054000000
2000000
250231000000
999997000000
1000000...

result:

ok 200000 lines

Test #23:

score: 0
Accepted
time: 25ms
memory: 15340kb

input:

1 200000
1000000 1 1000000
999999 999999
397566
714299
999992
595860
999997
2
191908
10
5
562337
903315
6
1
10
796224
8
594507
999997
690529
856723
48324
999999
786610
2
3
999992
958713
332059
233195
999995
5
65197
6
999992
754507
663503
13009
581668
216612
653317
510740
13809
653724
999994
6
783667...

output:

397566
714299
999992
595860
999997
2
191908
10
5
562337
903315
6
1
10
796224
8
594507
999997
690529
856723
48324
-1
786610
2
3
999992
958713
332059
233195
999995
5
65197
6
999992
754507
663503
13009
581668
216612
653317
510740
13809
653724
999994
6
783667
1000000
999990
-1
733191
999995
929153
9
484...

result:

ok 200000 lines

Test #24:

score: 0
Accepted
time: 27ms
memory: 15568kb

input:

1 200000
1000000 1000000 1000000
999999 999999
858950
1
5
999993
999999
472917
999992
524703
8
62720
616928
2
453573
924939
10
164592
763671
999995
53019
124724
728051
999999
5
7
58104
6
2
886022
74483
999990
1
999996
1000000
614281
958044
570103
238595
6
551138
999991
846608
799139
922508
6
999994
...

output:

858950000000
1000000
5000000
999993000000
-1
472917000000
999992000000
524703000000
8000000
62720000000
616928000000
2000000
453573000000
924939000000
10000000
164592000000
763671000000
999995000000
53019000000
124724000000
728051000000
-1
5000000
7000000
58104000000
6000000
2000000
886022000000
744...

result:

ok 200000 lines

Test #25:

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

input:

1 200000
1000000000000 1 1
999999 999999
999990
181070
850132
6
679579
705538
7
592384
395357
865806
999995
3
999999
347161
9
6
999992
8
360528
1
2
999995
999992
40876
466962
27108
662634
10
8
999996
387926
999997
912352
437299
999994
1000000
999996
999994
999995
3
999997
955868
7
461068
2
245958
99...

output:

999990
181070
850132
6
679579
705538
7
592384
395357
865806
999995
3
-1
347161
9
6
999992
8
360528
1
2
999995
999992
40876
466962
27108
662634
10
8
999996
387926
999997
912352
437299
999994
-1
999996
999994
999995
3
999997
955868
7
461068
2
245958
999991
4
235714
7
999995
909848
7
678849
999994
5
35...

result:

ok 200000 lines

Test #26:

score: 0
Accepted
time: 11ms
memory: 15340kb

input:

1 200000
1000000000000 1000000 1
999999 999999
999999
98142
614960
1
896987
999992
5
873172
999997
686921
882660
710605
542929
2
953123
1000000
340814
722148
5
35758
8
5
307994
658223
999997
8
444255
2
5
910389
999998
576597
7
6
999996
676990
999990
692843
999998
8
2
560138
184038
78689
4849
908023
...

output:

-1
98142000000
614960000000
1000000
896987000000
999992000000
5000000
873172000000
999997000000
686921000000
882660000000
710605000000
542929000000
2000000
953123000000
-1
340814000000
722148000000
5000000
35758000000
8000000
5000000
307994000000
658223000000
999997000000
8000000
444255000000
200000...

result:

ok 200000 lines

Test #27:

score: 0
Accepted
time: 20ms
memory: 15376kb

input:

1 200000
1000000000000 1 1000000
999999 999999
212412
999996
319493
7
208889
999995
10
951178
999999
10
999994
1000000
329956
249701
770805
232184
7
7
862340
5
999998
4
999994
173822
626090
522620
315027
9
3
10
999994
721016
7
10
4
520616
999990
659325
109033
9
999997
10
987068
5
677651
984607
5
999...

output:

212412
999996
319493
7
208889
999995
10
951178
-1
10
999994
-1
329956
249701
770805
232184
7
7
862340
5
999998
4
999994
173822
626090
522620
315027
9
3
10
999994
721016
7
10
4
520616
999990
659325
109033
9
999997
10
987068
5
677651
984607
5
999990
720823
298733
999997
10
999998
481575
144004
833831
...

result:

ok 200000 lines

Test #28:

score: 0
Accepted
time: 17ms
memory: 15500kb

input:

1 200000
1000000000000 1000000 1000000
999999 999999
701915
275155
6
999997
872219
999999
977750
1000000
896614
999997
999996
999997
765121
999993
260229
999992
671681
999991
999996
999993
655970
9
252271
5
9
400099
204315
656036
999992
455708
10
252533
109626
125883
999993
627105
999992
781243
4
14...

output:

701915000000
275155000000
6000000
999997000000
872219000000
-1
977750000000
-1
896614000000
999997000000
999996000000
999997000000
765121000000
999993000000
260229000000
999992000000
671681000000
999991000000
999996000000
999993000000
655970000000
9000000
252271000000
5000000
9000000
400099000000
20...

result:

ok 200000 lines

Subtask #2:

score: 0
Runtime Error

Test #29:

score: 0
Runtime Error

input:

1938 1960
999999 47694 9291
2883622 3085639
3674880 3745876
9982198101 9982517489
19960889157 19960925795
19962228551 19962276101
19964301694 19964730442
19964826417 19965369252
19965984922 19966442459
19968019821 19968213820
19968334967 19968392242
19968426638 19968840337
19969017519 19969109591
19...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #44:

score: 0
Runtime Error

input:

198085 196577
999999 1 999999
562622 895604
1799586 1975565
2518299 2941986
4934097 5403130
5755102 5996130
6036200 6112534
6391882 6431514
6451793 6555786
6613625 6621089
7130933 7204522
7335426 7522555
7748545 7784568
8184979 8494887
9066856 9178094
9303615 9384897
9716200 9719420
11693951 1183563...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%