QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#832808#9322. Segments RemovalhxhhxhAC ✓412ms83212kbC++231.6kb2024-12-26 08:39:212024-12-26 08:39:22

Judging History

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

  • [2024-12-26 08:39:22]
  • 评测
  • 测评结果:AC
  • 用时:412ms
  • 内存:83212kb
  • [2024-12-26 08:39:21]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
struct SEG{
	struct st{
		int l,r,c,z;
	}a[1048888];
	void bt(int x,int l,int r){
		a[x].l=l;
		a[x].r=r;
		a[x].c=a[x].z=0;
		if(l<r){
			bt(x<<1,l,(l+r>>1));
			bt(x<<1|1,(l+r>>1)+1,r);
		}
	}
	void ps(int x,int v){
		a[x].c+=v,a[x].z+=v;
	}
	void xf(int x){
		ps(x<<1,a[x].z),ps(x<<1|1,a[x].z);
		a[x].z=0;
	}
	void add(int x,int l,int r,int v){
		if(a[x].l==l&&a[x].r==r) return ps(x,v);
		if(a[x].z) xf(x);
		int mid=a[x].l+a[x].r>>1;
		if(r<=mid) add(x<<1,l,r,v);
		else if(l>mid) add(x<<1|1,l,r,v);
		else add(x<<1,l,mid,v),add(x<<1|1,mid+1,r,v);
		a[x].c=max(a[x<<1].c,a[x<<1|1].c);
	}
	int que(int x,int l,int r){
		if(a[x].l==l&&a[x].r==r) return a[x].c;
		if(a[x].z) xf(x);
		int mid=a[x].l+a[x].r>>1;
		if(r<=mid) return que(x<<1,l,r);
		if(l>mid) return que(x<<1|1,l,r);
		return max(que(x<<1,l,mid),que(x<<1|1,mid+1,r)); 
	}
}T;
int n,V,w[500005],ans;
vector<int>e[500005];
vector<pair<int,int> >g[500005];
multiset<int>s; 
void doing(){
	scanf("%lld %lld",&n,&V);
	T.bt(1,ans=0,V);
	for(int i=1;i<=V;i++) e[i].clear(),g[i].clear();
	for(int i=1,j,k,l,o;i<=n;i++){
		scanf("%lld %lld %lld %lld",&j,&k,&l,&o);
		e[j].push_back(l),e[k+1].push_back(-l);
		g[k].push_back({j,o}),ans-=o;
	}
	s={0};
	for(int i=1;i<=V;i++){
		for(int j:e[i]) j>0?s.insert(j):s.erase(s.find(-j));
		w[i]=*--s.end();
	}
	for(int i=1,l=0;i<=V;i++){
		for(auto j:g[i]) T.add(1,0,j.first-1,j.second);
		T.add(1,i,i,l=max(T.que(1,0,i-1),l+w[i]));
	}
	printf("%lld\n",ans+T.que(1,V,V));
}
signed main(){
	int T;
	cin>>T;
	while(T--) doing();
}

詳細信息

Test #1:

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

input:

2
3 8
3 7 3 2
5 8 2 1
1 3 2 2
2 5
1 3 2 7
3 5 3 4

output:

16
2

result:

ok 2 number(s): "16 2"

Test #2:

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

input:

5
3 7
3 7 8 6
2 4 6 8
3 3 8 3
3 6
1 3 7 6
2 2 6 6
4 5 4 6
4 6
2 4 7 4
2 6 5 3
2 3 4 6
1 1 3 6
4 7
1 3 2 5
1 6 3 3
5 5 8 5
1 6 5 1
1 4
2 2 8 8

output:

29
11
18
19
0

result:

ok 5 number(s): "29 11 18 19 0"

Test #3:

score: 0
Accepted
time: 58ms
memory: 7912kb

input:

26334
4 21
15 16 5 10
7 7 14 46
5 7 9 10
11 18 17 49
4 22
4 17 8 30
5 12 11 35
8 11 3 21
12 16 1 10
5 8
1 1 8 27
5 7 1 26
7 8 3 34
1 6 13 34
6 7 18 13
4 9
6 8 7 31
5 9 14 21
8 9 16 50
2 8 7 49
5 9
5 5 12 19
1 5 5 22
4 6 14 18
7 9 10 40
2 6 11 7
5 24
9 22 14 4
17 21 11 37
12 23 2 26
7 9 19 12
8 22 20...

output:

85
40
5
0
8
213
81
260
17
157
189
13
43
182
48
148
55
0
177
196
167
94
205
150
59
306
269
117
0
166
118
0
79
142
189
7
70
33
176
7
41
17
183
27
19
18
0
0
243
216
50
45
54
203
141
18
0
60
171
2
246
236
113
8
182
0
0
74
154
12
136
92
42
86
22
83
59
270
144
45
18
153
145
0
56
0
90
37
63
18
129
0
103
0
...

result:

ok 26334 numbers

Test #4:

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

input:

93
9 73
37 40 87 143
17 26 42 24
65 65 40 7
39 66 77 169
50 70 32 156
72 73 11 59
43 69 81 38
23 55 82 199
16 64 59 29
16 94
43 62 24 141
72 82 73 137
6 61 72 39
74 84 28 56
40 93 29 170
4 92 25 109
62 87 98 183
60 93 69 56
11 55 15 102
11 25 11 83
23 60 17 170
10 49 46 141
14 49 65 162
44 49 35 113...

output:

3540
5279
2023
5193
6123
7240
5272
2912
2957
1388
3536
752
4500
1850
1820
1456
0
3164
6362
1764
3546
3017
2025
5928
1283
3982
2944
0
798
5290
413
0
223
2019
3679
0
662
3215
1792
0
580
2467
3999
1929
503
489
2520
0
659
2179
2235
1019
2634
4045
5257
6497
0
2788
5826
2379
3453
2802
3704
648
1566
470
0
...

result:

ok 93 numbers

Test #5:

score: 0
Accepted
time: 59ms
memory: 8008kb

input:

9005
9 74
44 64 64 40
6 72 70 144
55 63 65 156
53 60 50 134
38 60 45 66
38 53 6 178
18 69 25 27
43 57 98 54
24 64 34 184
5 69
31 57 27 133
17 57 57 171
39 61 37 158
3 44 65 68
43 67 16 81
8 18
4 5 15 105
12 18 11 100
3 9 26 96
5 7 4 42
2 16 99 180
3 6 42 2
8 17 60 63
4 10 79 189
18 51
7 38 65 3
16 1...

output:

4127
3104
779
2508
3387
0
985
526
0
748
6061
1165
3004
8321
2602
0
1615
154
154
5503
5381
5006
886
3371
1197
5258
4574
0
2878
209
3953
137
1643
4966
2120
851
2326
904
3321
3099
551
3032
113
4146
0
3307
1571
3223
5923
2633
4473
3917
3061
1078
5511
348
5231
2039
5192
1350
4874
5339
3769
809
4622
0
153...

result:

ok 9005 numbers

Test #6:

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

input:

21
81 385
9 30 74 102
4 27 81 94
52 56 49 79
268 292 57 140
285 372 81 88
84 228 78 39
278 313 7 111
256 364 41 43
260 342 88 26
69 286 33 118
109 210 82 32
150 307 17 46
123 380 45 115
193 355 42 123
166 181 73 65
171 305 78 119
118 275 21 130
212 271 22 88
71 255 69 66
188 189 31 135
23 228 79 119...

output:

29555
1890
16624
18147
15747
27451
7589
2929
3526
20292
12641
20834
6842
25923
24707
29817
16405
27905
30622
11751
66

result:

ok 21 numbers

Test #7:

score: 0
Accepted
time: 102ms
memory: 8004kb

input:

2211
64 151
14 67 71 34
24 43 93 30
65 70 85 142
31 46 33 92
2 118 91 109
13 59 97 69
5 103 9 15
98 129 89 145
108 125 39 17
33 123 74 129
36 61 79 15
62 68 45 61
33 133 38 7
4 46 84 106
17 135 85 73
116 130 96 66
41 129 45 35
48 59 16 86
50 81 7 107
3 19 24 47
56 144 8 135
5 136 2 93
44 110 20 75
8...

output:

9390
1543
14313
3822
16301
23315
31974
8768
18180
0
7508
10327
26853
21613
18488
27048
25790
29429
17938
31486
14150
18576
18386
3105
16425
11533
13005
19767
28741
19902
3292
10975
32139
15298
14652
10120
5306
12981
9458
33917
3906
24214
13807
17881
8245
10968
2272
27689
9007
16203
20666
0
22353
286...

result:

ok 2211 numbers

Test #8:

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

input:

10
252 708
384 437 9298 8012
45 554 8309 9266
107 527 1452 8953
283 292 7316 459
418 647 3260 2424
215 523 7320 5230
326 590 3792 5140
191 634 6942 8233
244 561 6436 3945
250 410 5140 9708
217 433 2870 812
224 611 9861 7535
63 130 4450 7944
15 690 4160 2750
256 643 9014 3393
611 633 8432 6943
245 41...

output:

5623123
6432198
6555131
4677011
4098146
8046097
6900062
5655255
8026575
27037638

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 104ms
memory: 8132kb

input:

660
193 661
109 487 4459 602
436 650 6875 9280
176 458 4587 7522
67 335 4383 4385
276 654 6816 160
89 507 7706 3323
148 218 9260 9484
284 643 4284 7635
344 409 6097 3309
67 162 2935 7917
332 337 5774 7457
236 506 8971 8771
28 253 3478 943
295 512 5035 1084
142 221 729 6764
475 639 3558 1591
33 632 1...

output:

5381915
8434944
5120445
6859365
5793773
5659234
5504362
5722861
4577527
8346832
7910199
4685758
6677227
7477545
5923882
4982826
5964354
6172552
8439055
6732817
8281815
5882356
7466020
7745350
7601386
3880698
5645967
4269683
4862151
7330334
4753760
6303811
4395372
6907345
6624738
3991566
4012319
4358...

result:

ok 660 numbers

Test #10:

score: 0
Accepted
time: 143ms
memory: 13072kb

input:

48
2565 5244
3230 5070 239 8097
358 1832 11366 6498
1522 4105 3434 2230
727 5123 1825 999
3371 5068 15818 11350
147 827 13212 5669
174 2760 16832 13651
30 2493 6776 16071
1422 2317 17494 10365
476 4285 17834 4
1026 2244 10151 8886
2871 4060 12756 10031
2559 4380 15723 13207
1432 1931 979 1535
2464 3...

output:

76873539
346420042
68953885
0
12815844
138358930
179727531
357398559
300608224
81388186
160440721
22797011
220648670
307842471
50607083
151616962
129243407
113845386
295138617
39522001
260273707
325661445
358567392
145391681
280277141
340931319
1083441
343015210
253645027
123104048
359402744
3340537...

result:

ok 48 numbers

Test #11:

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

input:

6
2349 10255
3563 6399 3489 792
896 9277 1653 14924
4111 9608 2039 8420
2349 6415 1631 3610
1924 9788 8194 4676
7969 8691 6688 11304
1413 3874 11964 7617
2697 7114 12064 10743
1745 3557 15589 18031
2961 8406 7475 4092
4877 6288 7246 16700
542 1554 18085 8717
331 521 3566 17336
2446 8113 1596 11081
4...

output:

174408220
77403534
8714986
202782822
284230714
70926494

result:

ok 6 numbers

Test #12:

score: 0
Accepted
time: 195ms
memory: 53668kb

input:

45
4251 4863
4042 4325 12363 2231
260 2869 3451 2703
747 2337 5880 3357
1705 3823 261 17529
1576 1956 16464 14769
849 2122 13724 18227
771 1745 175 12292
397 1756 10500 13258
1607 2901 11051 15271
589 3982 15276 10803
3487 3670 4736 14138
2701 4704 14664 11011
961 2882 19187 6334
96 121 6941 19179
6...

output:

54795132
0
44218396
0
0
0
55107879
14237198
0
36704054
8194067
5642
32723572
2662
401330
2207926
0
42611450
7626769
14352006
35121019
49282109
0
41737468
47244193
47951664
0
13638257
0
4277051
0
32960721
30673332
6305833
48987142
0
31790739
23524304
0
0
41118994
0
53444333
18956439
7464700096

result:

ok 45 numbers

Test #13:

score: 0
Accepted
time: 15ms
memory: 16604kb

input:

5
4490 2270
900 1528 4653 14244
1735 1867 18379 13741
568 1543 18284 19221
793 1378 11906 19449
502 2022 6134 7721
1542 2096 3081 17497
139 2059 11903 19811
608 1999 8815 10407
242 656 13636 2202
161 218 9919 688
587 1343 3946 1154
197 845 10670 19385
353 630 390 12213
976 1843 2426 15334
1009 2130 ...

output:

0
0
17529128
26245314
767950220

result:

ok 5 number(s): "0 0 17529128 26245314 767950220"

Test #14:

score: 0
Accepted
time: 293ms
memory: 69536kb

input:

4
50497 85721
67683 73982 13110834 21807955
30272 42195 8010049 6743351
3095 9037 6980362 14974033
44110 77930 10347513 12811232
10020 37595 12990784 1861862
58595 60234 10585767 21260865
6391 33600 16610677 13834434
75272 84570 1947635 9799512
45101 58508 16726271 22760074
48244 65620 10191758 1777...

output:

900358283174
0
223697224766
6083605344200

result:

ok 4 number(s): "900358283174 0 223697224766 6083605344200"

Test #15:

score: 0
Accepted
time: 400ms
memory: 83196kb

input:

1
200000 500000
347278 439163 2518709 6422059
271971 458418 1394627 15790355
158237 405291 2371612 19085126
116147 144184 609859 6896213
60924 228239 166886 861584
90627 345053 1698306 4386959
135675 452655 1944698 591054
33182 453202 969231 18160170
11834 378790 1779703 5153346
172641 185203 210453...

output:

2000042

result:

ok 1 number(s): "2000042"

Test #16:

score: 0
Accepted
time: 408ms
memory: 83124kb

input:

1
200000 500000
149075 481227 245326838 532767985
312742 403661 88830551 152179271
246892 329662 334801351 415624461
30468 221901 386783637 362181319
358499 364854 885611032 891408801
353325 379699 254199592 880238312
211570 375604 61570211 523199375
23858 305255 195000554 510944427
178761 386338 98...

output:

399922493362335

result:

ok 1 number(s): "399922493362335"

Test #17:

score: 0
Accepted
time: 223ms
memory: 44624kb

input:

5
20350 77654
19963 51737 500161231 554626185
33156 73035 256000127 565329720
21888 50814 122426716 745153786
32999 41640 747093081 674760800
7345 57718 542872715 942166203
28027 45261 32189869 781779107
21605 38395 472640669 734787187
11530 34646 650366429 278346954
7820 8100 882707987 716925195
44...

output:

67372713365067
25316435840296
120614342614354
200339719996438
13364838393390

result:

ok 5 number(s): "67372713365067 25316435840296 ... 200339719996438 13364838393390"

Test #18:

score: 0
Accepted
time: 337ms
memory: 51656kb

input:

2
100000 250000
24424 224465 1720058 879820
34026 80039 3703916 1405105
18821 188406 2942515 2201554
45709 78080 6007750 54641
149193 185102 8106019 1760604
11733 104588 4480705 699436
74254 208667 4810499 282910
128495 228504 262572 547044
83590 244709 1523577 295569
22364 95422 8301757 1766402
333...

output:

2062287118871
2062654523566

result:

ok 2 number(s): "2062287118871 2062654523566"

Test #19:

score: 0
Accepted
time: 104ms
memory: 11480kb

input:

2058
28 60
32 34 27 10
43 44 19 1
37 40 30 1
12 13 29 12
10 12 1 19
9 10 10 16
8 9 35 5
32 37 5 7
38 39 3 23
16 17 5 6
8 9 38 5
21 25 29 12
3 5 29 17
57 59 35 10
29 32 8 13
24 27 37 6
43 44 24 7
35 36 21 3
2 4 13 9
9 10 11 4
2 6 30 5
8 10 12 14
44 45 8 14
2 4 35 1
14 15 38 23
15 16 34 7
44 45 33 23
...

output:

895
2653
2453
1226
1830
1307
2184
751
1314
1697
2070
3951
1841
2694
1904
634
1913
395
1605
1652
1264
3002
1469
1886
320
496
3117
928
379
1485
2453
1316
2833
2754
2575
2374
1763
160
2318
2641
1375
3463
1009
377
800
1621
923
1231
2974
1684
2052
2502
1649
1268
448
2069
1344
1057
2199
1163
2158
2758
109...

result:

ok 2058 numbers

Test #20:

score: 0
Accepted
time: 105ms
memory: 11320kb

input:

2079
27 326
47 51 36 15
73 83 6 12
187 192 6 23
139 141 31 20
44 45 16 2
253 254 1 3
134 138 11 11
158 161 12 3
159 166 5 15
35 36 27 20
48 50 24 2
32 37 25 2
125 131 23 1
119 127 12 2
109 116 29 8
52 55 39 19
89 93 31 5
89 94 6 22
112 116 23 2
130 137 39 3
228 231 14 4
11 14 14 11
158 167 24 12
36 ...

output:

1911
4078
2865
4012
1778
2884
4257
3637
2820
1698
3621
3143
2330
686
3800
3962
4035
3535
4042
1946
2429
2078
3584
3829
2993
4729
4770
2137
887
2600
3601
5182
2205
2738
1196
2869
4462
1335
5136
1932
4284
3295
2135
2771
2928
3817
5178
3949
3845
2916
1762
3559
2483
2501
723
3169
1485
351
3024
1011
571
...

result:

ok 2079 numbers

Test #21:

score: 0
Accepted
time: 106ms
memory: 11116kb

input:

2070
57 363
116 118 40 14
91 93 33 4
26 29 2 25
166 170 4 7
321 324 36 10
174 175 21 14
112 114 27 19
41 42 9 13
10 13 38 22
326 331 29 5
49 50 13 12
95 98 20 15
119 122 2 19
29 33 10 23
144 146 35 10
115 118 39 4
9 10 13 2
352 353 31 16
80 82 4 17
87 88 12 9
81 83 19 5
209 212 37 17
61 62 26 22
28 ...

output:

2243
1311
2757
2349
2569
3689
3487
3572
1849
1950
1997
722
2591
1749
3007
3873
2956
3296
311
956
3354
2213
2212
1072
2783
2454
2986
2095
2818
2229
4118
565
850
1951
2710
870
1144
953
1828
1483
845
1162
178
2475
3343
3583
889
1084
1330
3343
1873
2526
654
1230
2294
2692
2557
2252
1602
1806
427
1263
25...

result:

ok 2070 numbers

Test #22:

score: 0
Accepted
time: 203ms
memory: 18304kb

input:

13
15484 47752
14006 14309 2016 1786
31254 32428 272 806
20953 21038 2512 176
23230 23333 1867 1057
3946 4891 9956 377
10490 11130 3755 1576
26659 26989 3439 1847
13630 13737 2234 460
6297 6472 3775 149
28710 28788 7780 678
5953 6956 5099 216
14663 15083 6892 670
15466 15790 448 775
10913 10994 8704...

output:

451378957
357989782
308476805
453874682
327455270
421935951
425889112
439644324
284157281
351183066
355340082
429347116
86856841

result:

ok 13 numbers

Test #23:

score: 0
Accepted
time: 112ms
memory: 11992kb

input:

2058
28 60
32 37 27 10
43 47 19 1
37 41 30 1
12 17 29 12
10 13 1 19
9 13 10 16
8 13 35 5
32 38 5 7
38 40 3 23
16 21 5 6
8 11 38 5
21 26 29 12
3 9 29 17
57 60 35 10
29 35 8 13
24 30 37 6
43 48 24 7
35 39 21 3
2 8 13 9
9 13 11 4
2 7 30 5
8 13 12 14
44 46 8 14
2 7 35 1
14 15 38 23
15 21 34 7
44 50 33 2...

output:

1462
4998
4356
2212
3764
2779
3552
1018
2618
3072
3603
6624
2667
4586
3242
963
2810
723
2725
3033
2102
5320
2327
3323
525
722
5189
1404
440
3312
4866
2110
4682
4684
5172
3325
3126
179
4367
4553
2596
6375
1286
693
1559
3158
1238
1983
5192
3362
3353
5317
3165
2446
736
3599
2614
1577
3875
2342
3789
502...

result:

ok 2058 numbers

Test #24:

score: 0
Accepted
time: 113ms
memory: 11432kb

input:

2079
27 326
47 61 36 15
73 88 6 12
187 201 6 23
139 152 31 20
44 59 16 2
253 259 1 3
134 142 11 11
158 163 12 3
159 170 5 15
35 49 27 20
48 62 24 2
32 47 25 2
125 135 23 1
119 128 12 2
109 120 29 8
52 63 39 19
89 104 31 5
89 96 6 22
112 119 23 2
130 141 39 3
228 242 14 4
11 24 14 11
158 172 24 12
36...

output:

3879
7028
4382
6972
2973
3664
6660
5342
5042
2414
6394
5714
5147
870
6428
7956
7935
6373
5228
3148
3377
4213
6750
6111
4889
7473
7873
4196
1438
2900
5754
6622
2899
4509
1514
3671
6208
2208
8479
3170
6931
4696
3735
3957
4693
4899
7978
5689
5444
4857
5398
5541
3833
4518
808
4424
2128
521
4300
1351
870...

result:

ok 2079 numbers

Test #25:

score: 0
Accepted
time: 113ms
memory: 11656kb

input:

2070
57 363
116 123 40 14
91 99 33 4
26 34 2 25
166 173 4 7
321 327 36 10
174 183 21 14
112 121 27 19
41 50 9 13
10 19 38 22
326 335 29 5
49 56 13 12
95 104 20 15
119 127 2 19
29 34 10 23
144 153 35 10
115 121 39 4
9 17 13 2
352 360 31 16
80 85 4 17
87 93 12 9
81 89 19 5
209 216 37 17
61 63 26 22
28...

output:

4818
3086
4699
4605
5476
6517
5748
5776
2911
3168
3208
1128
4351
3292
4341
6622
4743
6809
504
1820
6175
4558
3080
1986
4905
5620
5899
2879
5158
2901
7114
1250
1296
3014
5121
1318
2643
1552
3766
2187
1779
2573
284
3713
6090
6739
1117
2537
1955
4836
3685
3795
873
3094
4434
4304
4989
4994
2360
3474
613...

result:

ok 2070 numbers

Test #26:

score: 0
Accepted
time: 193ms
memory: 20424kb

input:

13
15484 47752
14006 15628 2016 1786
31254 32824 272 806
20953 22498 2512 176
23230 24645 1867 1057
3946 5518 9956 377
10490 12190 3755 1576
26659 27924 3439 1847
13630 14496 2234 460
6297 8022 3775 149
28710 30311 7780 678
5953 7333 5099 216
14663 16363 6892 670
15466 17062 448 775
10913 12232 8704...

output:

457224296
360850998
311107313
460697759
331401601
428481812
429546478
451189852
286606131
354118929
360547903
434613604
86964285

result:

ok 13 numbers

Test #27:

score: 0
Accepted
time: 238ms
memory: 43228kb

input:

4
50000 100000
79328 79550 548171 395565
30649 30727 971998 530561
60693 61218 430807 770720
6426 6545 80291 31331
15469 15507 129209 136819
54472 54590 672702 291261
22958 23186 31453 569185
48441 48764 621165 593772
44197 44259 354949 611598
6287 6544 175938 57410
81185 81894 49143 341820
46613 47...

output:

69524426125
70033511569
69523922422
164517395648

result:

ok 4 number(s): "69524426125 70033511569 69523922422 164517395648"

Test #28:

score: 0
Accepted
time: 275ms
memory: 44116kb

input:

4
50000 100000
28524 40706 854428 267587
19687 26694 132412 360526
52921 80861 945300 1103818
20541 45960 146334 423274
14073 90831 603590 665675
12962 26576 988840 955115
35296 93246 635273 821081
68710 100000 428147 104419
33141 48072 276354 767424
16181 26703 538308 70212
34747 100000 859526 3128...

output:

71937427217
71856687409
71755854424
171821058863

result:

ok 4 number(s): "71937427217 71856687409 71755854424 171821058863"

Test #29:

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

input:

4
50000 100000
79328 80147 548171 395565
30649 31670 971998 530561
60693 61422 430807 770720
6426 7369 80291 31331
15469 16246 129209 136819
54472 55253 672702 291261
22958 23588 31453 569185
48441 49400 621165 593772
44197 44412 354949 611598
6287 7223 175938 57410
81185 82130 49143 341820
46613 47...

output:

70930986051
71412326514
71223033738
169570706518

result:

ok 4 number(s): "70930986051 71412326514 71223033738 169570706518"

Test #30:

score: 0
Accepted
time: 270ms
memory: 44512kb

input:

4
50000 100000
28524 100000 854428 267587
19687 100000 132412 360526
52921 100000 945300 1103818
20541 98167 146334 423274
14073 100000 603590 665675
12962 100000 988840 955115
35296 100000 635273 821081
68710 100000 428147 104419
33141 100000 276354 767424
16181 84892 538308 70212
34747 100000 8595...

output:

71939806324
71858983221
71766492878
171869712446

result:

ok 4 number(s): "71939806324 71858983221 71766492878 171869712446"

Test #31:

score: 0
Accepted
time: 139ms
memory: 13712kb

input:

78
1266 6397
588 3279 35231 9531563
5978 6321 62509 2108003
5622 6223 9267 4355805
4540 6358 79182 8331588
820 3883 22909 7606467
817 5414 7460 4080909
1259 3884 93164 4166998
296 389 57665 7890007
647 2639 58003 3766222
4481 5825 6358 7115260
2411 5096 63234 9935013
4295 4528 96499 8100883
2037 224...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
17091
0
9345
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20819
0
0
0
0
0
0
0
56932
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
49028
0
0
0
0
0
0
0

result:

ok 78 numbers

Test #32:

score: 0
Accepted
time: 412ms
memory: 83212kb

input:

1
200000 500000
36144 449330 46012289 165854277
15016 79772 43921316 489184647
183118 412506 64929053 711959440
353861 488739 64277676 559353657
208298 495775 42396516 106107342
36907 88492 3148077 442021776
150207 227783 19312451 24278581
248367 369669 139189 340423011
406091 411255 57914599 812315...

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 282ms
memory: 77932kb

input:

1
200000 500000
225475 225796 73051883 728409295
107208 107216 25737686 79592000
341799 341813 49515959 946358475
36231 36321 96348219 477457858
259474 259641 1034690 139897269
43437 44217 67570931 234701380
244615 244617 49965456 405784695
404285 404471 85599558 180605945
83212 83827 22771612 67173...

output:

5104603960911

result:

ok 1 number(s): "5104603960911"

Test #34:

score: 0
Accepted
time: 305ms
memory: 78384kb

input:

1
200000 500000
422483 424543 28935562 471311724
246709 251054 41875322 131172020
163534 167753 13686894 893662726
44122 48562 47009455 669991619
284346 288051 30424084 284036954
148487 154190 50379313 31269069
16875 19070 58365320 660106348
318914 322141 89421177 848218045
98406 101110 4243164 7437...

output:

5898895147762

result:

ok 1 number(s): "5898895147762"

Test #35:

score: 0
Accepted
time: 331ms
memory: 78956kb

input:

1
200000 500000
17828 42108 52833352 556238586
316249 324763 64131459 521939459
93917 106689 93280596 991816958
143484 149759 82014342 382799379
166857 236025 74539608 583785642
133988 177494 73266494 920446751
90592 106393 52497083 459256704
5534 19836 88074654 608447057
38278 68900 89878693 811273...

output:

3642641652401

result:

ok 1 number(s): "3642641652401"

Test #36:

score: 0
Accepted
time: 288ms
memory: 78000kb

input:

1
200000 500000
225475 226400 73051883 728409295
107208 108127 25737686 79592000
341799 342743 49515959 946358475
36231 36895 96348219 477457858
259474 260217 1034690 139897269
43437 44384 67570931 234701380
244615 245489 49965456 405784695
404285 404567 85599558 180605945
83212 84207 22771612 67173...

output:

5760021808492

result:

ok 1 number(s): "5760021808492"

Test #37:

score: 0
Accepted
time: 308ms
memory: 78240kb

input:

1
200000 500000
422483 431506 28935562 471311724
246709 255387 41875322 131172020
163534 169634 13686894 893662726
44122 51373 47009455 669991619
284346 291159 30424084 284036954
148487 156567 50379313 31269069
16875 24327 58365320 660106348
318914 326414 89421177 848218045
98406 102939 4243164 7437...

output:

5462301939532

result:

ok 1 number(s): "5462301939532"

Test #38:

score: 0
Accepted
time: 379ms
memory: 80228kb

input:

1
200000 500000
17828 94004 52833352 556238586
316249 411889 64131459 521939459
93917 148940 93280596 991816958
143484 217989 82014342 382799379
166857 247722 74539608 583785642
133988 212126 73266494 920446751
90592 161358 52497083 459256704
5534 40827 88074654 608447057
38278 100398 89878693 81127...

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 68ms
memory: 10800kb

input:

89
39 8333
5 36 531035830 176400643
5 72 161123033 799981618
8314 8319 493969454 580741942
8311 8319 519435341 869224551
8286 8319 912313060 119340429
8293 8319 691833902 583174802
8237 8319 240532654 510585736
5 45 902042633 661925264
5 68 937311254 946494848
5 60 866159222 21111899
8313 8319 44981...

output:

127756206562
140968549906
141633847862
137900616081
152807379640
119777204602
153151327644
85970922526
138759495020
138735260546
132468495106
147394364699
143111973914
125231448350
129176307105
146235326647
89588176545
82876899770
125290393613
131829313542
107981929377
130273311058
139159833135
1160...

result:

ok 89 numbers

Test #40:

score: 0
Accepted
time: 192ms
memory: 47628kb

input:

7
39725 32345
28325 32264 293087508 788222554
21 1043 502026990 674155464
28325 32333 490254457 42608798
43 1043 677668257 711216189
28325 32290 368308033 577249312
68 1043 939963721 947194298
28325 32277 885598393 167388245
28325 32268 693828787 315698416
28325 32255 260219924 547547205
28325 32329...

output:

0
0
653663352752
0
0
0
0

result:

ok 7 numbers

Test #41:

score: 0
Accepted
time: 216ms
memory: 29984kb

input:

2
100000 250000
237680 249944 390261887 497896593
237680 249994 475973891 352828691
237680 249908 441544420 795996962
73 10493 35481300 162129123
44 10493 145191218 736970484
92 10493 909755067 493459893
237680 249940 267349187 467384163
237680 249900 750957208 137555546
17 10493 400932571 960518695...

output:

0
0

result:

ok 2 number(s): "0 0"

Test #42:

score: 0
Accepted
time: 68ms
memory: 8464kb

input:

92
77 1486
1416 1425 351553525 904711452
22 32 257453454 33549955
15 55 623376524 644158747
1446 1449 114669022 622179739
1394 1432 737062981 234790176
1419 1428 588582764 54091452
4 22 105164070 715235156
1420 1434 330145771 848588721
1 62 85132848 442707714
11 25 700984883 572068937
1389 1433 1901...

output:

135564233177
117994259429
144624388958
140400874735
128947790959
132234406152
138450616536
129791590691
134083259927
140785277545
115593225060
135459832501
129476123637
128101345221
139144422428
127372968947
147521948769
128853517943
142949316002
124423067307
159769336638
141306158054
129964890714
1...

result:

ok 92 numbers

Test #43:

score: 0
Accepted
time: 215ms
memory: 48636kb

input:

6
45938 23465
1 23379 920858990 31524964
1 23448 318998078 13653734
65 21057 881439300 410907277
13 1876 226972562 785360377
14 21716 689674652 370992275
71 18550 682912442 642822124
1 23405 966654131 118511896
72 9191 871701979 282089527
1 23465 388375651 636603565
1 23386 85577713 488929971
1 2339...

output:

525964238578
17361217120336
0
6349296082846
5005180608987
202473629125

result:

ok 6 numbers

Test #44:

score: 0
Accepted
time: 281ms
memory: 39048kb

input:

2
100000 250000
161630 249944 231352930 914266982
98 28622 152309517 927794858
91 12576 224817746 263159920
32 36094 583545657 675090179
155997 249981 267572206 875810203
182892 249962 317551434 840245412
195712 249956 801743117 233999018
151572 249933 514863939 101792012
17 43770 184710022 82311165...

output:

100002008509024
100012412246278

result:

ok 2 number(s): "100002008509024 100012412246278"