QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574221#7436. Optimal Ordered Problem Solverucup-team340760 2565ms132684kbC++985.2kb2024-09-18 21:07:362024-09-18 21:07:36

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 3ms
memory: 68840kb

input:

995 996
950 481
376 18
141 776
711 966
130 727
468 529
47 39
857 563
832 821
776 472
154 914
825 279
332 415
470 361
968 440
45 560
299 755
703 785
744 387
547 382
3 549
344 573
778 424
784 765
280 115
251 434
695 98
463 506
379 38
610 486
305 623
703 244
856 365
117 360
772 847
331 723
663 991
900 ...

output:

423
473
758
313
694
232
333
784
821
154
247
244
504
54
200
370
872
782
734
174
660
467
76
754
77
3
144
974
526
415
439
694
507
577
258
120
243
3
2
319
313
498
218
828
433
623
981
700
120
55
70
499
375
283
387
128
317
139
220
410
22
547
3
385
430
168
32
0
178
625
677
561
488
672
577
64
144
537
235
54...

result:

ok 996 numbers

Test #2:

score: 20
Accepted
time: 3ms
memory: 69128kb

input:

1000 998
483 753
603 464
306 515
71 717
536 195
335 816
275 223
236 392
764 856
434 203
910 542
595 408
185 212
559 836
27 238
959 252
830 212
946 431
794 63
164 800
566 307
861 840
555 580
37 225
976 897
946 891
459 163
101 679
511 141
628 271
115 202
6 911
131 99
991 975
578 60
193 889
683 437
408...

output:

411
275
9
632
553
5
873
494
172
893
41
194
638
599
747
37
653
919
560
334
536
26
244
448
800
189
64
383
829
662
4
196
785
548
215
430
258
463
132
488
581
217
229
513
765
817
750
3
213
1
624
545
499
79
59
873
211
334
709
371
597
290
0
957
689
192
119
6
322
390
129
464
24
278
876
824
243
663
443
84
61...

result:

ok 998 numbers

Test #3:

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

input:

1000 995
301 895
261 325
211 404
100 381
849 291
851 65
272 465
786 647
26 15
779 368
356 74
26 196
308 809
532 229
643 707
426 380
152 371
622 652
905 793
847 322
574 197
117 960
339 751
246 87
322 948
511 800
967 25
36 906
278 611
586 991
392 314
933 644
42 569
948 769
982 134
518 314
741 491
800 ...

output:

423
240
474
705
507
222
71
715
306
761
254
570
660
638
797
511
581
691
577
876
695
607
230
812
266
89
79
690
456
514
337
549
916
430
79
563
524
372
690
388
853
54
923
388
850
142
307
460
416
605
263
68
928
644
607
911
471
599
455
620
151
2
748
305
88
282
993
59
574
381
568
238
340
644
566
747
0
119
...

result:

ok 995 numbers

Test #4:

score: 20
Accepted
time: 8ms
memory: 72400kb

input:

995 997
185 576
420 830
106 145
449 735
293 805
945 57
638 163
316 69
389 66
859 807
632 451
99 437
512 805
645 345
477 93
380 167
502 493
645 333
395 337
729 294
195 209
78 130
592 217
296 864
274 766
791 84
426 303
800 473
198 693
194 756
383 178
404 496
147 487
944 650
316 250
466 523
433 591
794...

output:

67
19
382
84
402
398
880
170
289
60
32
151
17
153
273
203
35
953
2
218
820
458
8
131
80
176
133
487
374
136
756
724
422
128
731
0
685
108
153
24
115
104
646
47
940
854
38
373
831
622
140
49
302
503
460
93
341
105
97
185
228
756
114
466
212
671
967
290
492
859
176
515
249
519
170
0
758
334
899
516
87...

result:

ok 997 numbers

Test #5:

score: 20
Accepted
time: 12ms
memory: 69048kb

input:

996 995
359 306
463 864
932 861
257 565
951 362
874 446
709 578
155 792
887 792
955 630
323 951
273 186
274 877
23 243
643 465
990 822
435 852
403 515
248 410
523 106
512 405
890 889
617 782
539 889
322 419
443 573
805 375
702 60
749 808
147 302
614 933
968 565
681 344
687 665
762 603
17 646
188 34
...

output:

136
742
755
119
569
60
718
478
674
77
676
593
64
132
6
43
797
750
603
229
693
791
874
899
149
61
417
609
132
243
752
409
504
165
901
647
105
175
743
569
468
877
526
0
52
217
792
190
421
343
457
0
696
29
408
40
0
725
467
11
357
402
545
129
761
512
369
573
428
57
5
912
103
876
64
85
257
386
742
760
67...

result:

ok 995 numbers

Test #6:

score: 20
Accepted
time: 4ms
memory: 73832kb

input:

1000 1000
863 244
541 217
420 994
514 373
675 10
137 518
258 267
691 946
517 233
522 726
468 850
698 633
677 591
651 270
739 673
119 385
213 71
2 177
480 66
398 68
233 965
808 316
883 346
486 966
116 926
850 663
129 22
665 370
6 911
38 919
124 555
236 350
12 98
261 510
124 565
294 447
703 338
408 37...

output:

876
833
394
566
775
762
88
202
176
781
306
2
948
563
855
224
953
842
506
326
857
786
428
443
707
975
120
165
67
93
750
775
412
446
850
777
563
399
922
305
169
556
60
12
122
349
935
363
826
415
94
94
221
668
997
779
0
15
355
824
978
12
772
916
365
21
462
487
87
641
9
871
488
586
813
861
791
30
270
12...

result:

ok 1000 numbers

Test #7:

score: 20
Accepted
time: 4ms
memory: 70976kb

input:

998 995
968 598
292 481
163 318
24 536
222 338
486 556
600 574
730 474
653 981
669 378
513 79
766 774
100 543
895 535
752 93
883 427
338 874
253 536
235 384
761 822
790 235
823 909
598 348
319 746
650 219
710 485
862 816
847 978
397 497
108 894
61 939
860 633
545 743
130 362
782 855
72 965
906 146
5...

output:

885
513
845
589
139
453
34
725
407
679
629
662
345
547
303
609
463
207
585
227
290
350
105
382
270
19
380
707
413
366
491
284
784
887
642
672
547
651
126
16
26
771
752
723
315
244
66
626
169
923
720
449
889
812
406
53
745
218
151
583
551
520
286
668
626
316
892
937
339
804
7
149
470
32
723
753
341
2...

result:

ok 995 numbers

Test #8:

score: 20
Accepted
time: 4ms
memory: 71232kb

input:

1000 1000
118 698
770 781
232 191
699 983
873 604
753 289
556 223
577 705
614 711
50 822
59 41
169 346
535 785
956 299
570 831
933 382
193 64
943 608
973 38
283 425
679 272
769 954
369 484
202 454
916 768
474 703
502 751
453 156
202 791
864 285
834 371
631 580
131 132
724 408
789 344
735 982
835 826...

output:

35
241
333
424
60
661
739
244
78
185
303
353
72
756
112
94
0
756
518
941
931
1
217
908
332
211
432
64
930
747
716
474
313
510
827
362
773
257
632
490
417
710
273
179
453
466
473
718
230
714
491
703
74
108
484
40
220
214
0
170
843
121
182
538
606
662
824
0
666
425
620
75
182
16
389
422
0
343
365
299
...

result:

ok 1000 numbers

Subtask #2:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 2171ms
memory: 131216kb

input:

999996 999996
921339 140126
955508 363759
958698 342406
280137 955674
907511 75721
189876 946586
152058 168837
541857 557702
84498 865987
185574 809224
704828 701026
815379 548000
989515 518951
335439 336866
745570 790616
766723 212893
926629 859003
51261 40866
592510 556235
324926 700261
320946 798...

output:

0
0
953730
0
0
512663
0
0
0
0
407467
0
0
0
0
420
0
0
0
0
0
0
513245
0
0
0
0
0
0
0
0
0
0
0
11756
0
0
7822
0
0
0
0
22726
0
0
0
8233
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
13818
349438
0
0
0
0
0
0
6803
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
8602
0
0
0
0
0
0
0
15717
0
0
0
0
0
0
0
0
0
0...

result:

ok 999996 numbers

Test #10:

score: 20
Accepted
time: 2452ms
memory: 130916kb

input:

999999 999998
593840 81071
226822 360556
984658 495723
774168 212723
961202 460976
425364 312068
135686 76747
312878 654073
77701 260718
263549 822714
513429 976716
926207 374094
338002 624578
897648 332005
630931 241967
134312 551284
743455 355739
997122 435568
642662 63663
795243 94444
696789 3776...

output:

491984
0
125735
422908
0
226183
0
0
0
2158
0
0
280064
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
19502
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
747
0
0
0
0
0
0
0
0
0
0
0
0
59265
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 999998 numbers

Test #11:

score: 20
Accepted
time: 2565ms
memory: 130812kb

input:

1000000 1000000
883777 318082
13863 878428
601471 340063
593065 648191
228224 432858
585884 205059
770071 963599
897140 940808
68907 32537
396365 642545
822913 211348
629556 82339
190410 157689
907562 173596
271125 337580
145399 606492
749603 897091
193876 205903
678121 530830
947890 589055
721497 7...

output:

261157
0
0
52244
0
0
0
0
4610
0
20801
505827
0
0
0
655799
0
0
0
0
0
163473
0
0
113182
0
0
556199
0
0
0
282902
197726
0
0
0
521870
0
0
0
0
0
0
0
0
0
0
146288
0
136329
0
0
0
0
0
91372
0
0
0
0
0
522077
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
181410
0
0
0
0
0
0
...

result:

ok 1000000 numbers

Test #12:

score: 20
Accepted
time: 2003ms
memory: 131924kb

input:

999999 999998
510701 119376
730813 348187
969509 347009
150616 323014
602592 62582
356110 705851
244692 610953
398605 700401
220533 880308
10280 261179
57162 967936
642021 39765
410482 274103
869979 489138
673553 368275
889697 840948
383673 63696
607963 107808
875626 9630
793170 959823
798227 760130...

output:

65013
21415
692431
0
388141
0
0
0
0
0
0
0
0
0
0
42859
0
0
0
0
0
0
0
0
0
0
8862
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
172112
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
1215
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
6288
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 999998 numbers

Test #13:

score: 20
Accepted
time: 1960ms
memory: 132684kb

input:

999995 999997
148480 214663
902145 539206
771718 173309
708903 967479
984809 352800
21198 668703
879442 719279
593199 82759
286519 788269
873747 641026
246815 368469
585243 532758
177189 437376
566499 996874
663718 794807
847945 784546
68802 611025
636042 793005
656312 200282
90301 316758
516692 913...

output:

408393
0
0
210017
0
0
0
0
0
0
0
0
0
0
0
0
0
0
34271
0
0
0
0
0
0
0
0
0
0
31774
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
624290
27190
0
0
0
0
0
0
0
0
2486
0
0
0
0
0
0
0
0
0
844
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10393
0
0
0
0
0
0
0
0
0
0
0
0
49019
0
0
0
19256
0
0
0
0
0
0
62458
0
0
0
0
0
0
...

result:

ok 999997 numbers

Test #14:

score: 20
Accepted
time: 2066ms
memory: 131824kb

input:

999997 999999
21022 22383
798350 250307
186761 593014
213847 210545
769838 227750
113146 776982
163493 384752
89954 142451
392976 865128
131868 401967
725617 848954
553332 555884
864058 712711
390463 443782
552326 132864
92265 612350
758766 28175
452611 460112
344799 865045
46279 695425
971996 40084...

output:

418555
110151
3026
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
33746
0
0
0
0
63321
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
0
0
0
0
60309
0
0
0
0
0
0
6997
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
3366
0
0
0
0
0
0
0
0
0
2...

result:

ok 999999 numbers

Test #15:

score: 20
Accepted
time: 2139ms
memory: 130976kb

input:

1000000 1000000
151138 713282
47031 196016
951306 826897
695178 570874
853734 782231
254275 640338
166145 420223
154398 814676
670384 826624
992734 757955
486563 187117
169107 198294
973559 847637
993679 950871
217983 940481
10443 754197
627178 253860
607235 514653
806520 269962
714084 706285
32303 ...

output:

493206
119482
243747
3831
0
30734
45299
0
84535
0
0
32866
0
0
0
0
0
0
663462
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
89699
0
76885
0
0
0
0
0
0
0
1347
0
0
0
114007
0
0
822812
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8470
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
518
0
0
946947
0
0
0
0
...

result:

ok 1000000 numbers

Test #16:

score: 20
Accepted
time: 2466ms
memory: 132536kb

input:

1000000 1000000
527391 935776
928283 415193
584695 629231
364709 289656
296798 845590
807666 903716
100319 286344
880595 598376
232292 301072
465491 18715
537421 144321
773917 271368
633706 520802
140917 281422
550382 123883
348051 422164
732339 760403
883443 660056
240883 539950
301009 698713
73859...

output:

956868
480655
0
0
3595
0
0
234921
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4511
0
0
0
975
446781
0
0
0
1210
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
897203
8983
0
0
0
0
0
0
0
0
0
0
0
0
953761
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 1000000 numbers

Subtask #3:

score: 0
Time Limit Exceeded

Test #17:

score: 0
Time Limit Exceeded

input:

999995 999997
261379 334440
985281 986034
549380 718157
670003 253925
533027 437989
326806 983213
965935 756259
229069 686789
331338 684961
957559 390618
937820 959719
338153 779814
582581 965418
634156 421264
308778 938878
913059 390904
481477 431492
739774 793015
901442 934600
256704 991485
366691...

output:


result:


Subtask #4:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #25:

score: 20
Accepted
time: 854ms
memory: 94824kb

input:

300000 300000
189563 143721
113019 232012
283009 152341
235960 146797
105782 100287
206719 212533
238247 192897
161513 101004
277069 129851
143907 67623
222005 158357
160618 31368
104158 90114
148304 15002
40521 169190
123876 140598
98925 113096
140488 204997
261142 106636
248565 219481
169567 27352...

output:

133975
58943
108003
271435
240472
18520
37226
64824
110443
24926
100107
57084
94462
77185
184644
44920
9569
36924
35679
185190
185985
59207
158326
295411
139708
12926
12708
66759
205320
8991
58151
18350
77099
21936
68243
193824
3369
33845
198412
152705
74697
80791
17996
195006
131057
125867
119782
4...

result:

ok 300000 numbers

Test #26:

score: 20
Accepted
time: 529ms
memory: 98636kb

input:

299996 299995
79019 129698
234860 13102
158780 130519
261477 120960
60568 211885
256377 296230
147012 276380
185086 180605
204971 176492
88129 293796
227141 23984
220343 191736
58992 215794
109290 47137
212346 145295
153762 283639
47157 61831
123097 99924
192275 67142
245853 133217
66762 222393
1151...

output:

131818
260140
3505
105184
9284
13024
251956
148517
174364
116271
35508
244852
118953
118474
103947
120727
281820
252822
180298
79580
281785
12209
210581
252212
1720
26573
27339
9033
43182
93870
263052
28232
20251
213930
3831
16733
47322
1601
11575
1448
196631
18062
199534
253177
147386
27733
84098
1...

result:

ok 299995 numbers

Test #27:

score: 20
Accepted
time: 929ms
memory: 104684kb

input:

299995 299996
188804 55811
167434 153058
154932 74503
173622 52433
26915 214178
234016 135998
15896 265764
8622 97137
227795 200595
48807 86677
33673 153470
152556 137563
266890 148077
94382 46942
282125 163817
268632 4779
234991 130657
187910 159651
79388 104610
233085 133115
150223 76879
54979 261...

output:

19418
250508
142313
50795
202976
270503
29304
38129
149746
192581
190066
194819
196136
137213
96812
14034
229385
45437
163195
236623
128107
160769
243153
98499
277308
250726
46463
246021
26467
77438
244641
158038
98826
2702
13513
127549
178416
26046
33066
57526
49752
126683
237234
111752
200579
2880...

result:

ok 299996 numbers

Test #28:

score: 20
Accepted
time: 941ms
memory: 93904kb

input:

300000 300000
287600 159144
154753 83801
270907 47305
204449 62527
191095 292913
144320 60580
93307 49515
3998 158033
282445 245654
145947 29326
92088 215104
277974 232931
26354 28648
70712 212065
10723 229150
150470 127263
9535 37547
23636 86990
236638 251737
80546 258533
262007 100054
12817 102109...

output:

247971
230684
161145
23290
227117
78047
82712
45112
32137
62021
38426
157008
60980
192430
120614
32520
155874
263799
127259
224499
38665
221398
7452
166265
51356
271847
31072
159795
233035
67072
107748
83341
22705
974
17753
83155
145154
160389
151396
210838
189311
57161
230585
21207
35195
219190
710...

result:

ok 300000 numbers

Test #29:

score: 20
Accepted
time: 845ms
memory: 97840kb

input:

299996 299998
184207 84911
287984 212458
244826 86388
197096 179170
44973 252282
172396 89784
102544 201463
22457 247915
95428 192248
85330 147275
156957 163186
54903 157709
28992 129096
163944 169142
292808 198914
1336 127387
119305 47621
148571 183483
209901 108145
251623 284161
183206 100059
1405...

output:

26149
69871
215541
1914
9018
90038
175590
120535
18222
162774
164013
118400
158442
97990
63361
175299
260728
55139
6618
3969
84166
196689
54864
39135
99707
227834
218578
214866
52660
241197
146719
21361
221940
27645
111387
19507
32703
133617
78042
283204
199994
75334
225998
287307
157383
20181
25588...

result:

ok 299998 numbers

Test #30:

score: 20
Accepted
time: 912ms
memory: 98788kb

input:

299996 299999
77650 14898
64549 295007
73990 219923
119584 280074
11286 11441
272839 28325
123199 3684
61093 88515
289951 214024
173865 243628
4479 136903
57898 46525
255260 212810
55907 23912
22768 241324
278290 242498
198303 64731
244399 7499
25694 122349
168625 247625
299288 255534
216462 140161
...

output:

143226
74062
207551
47856
141644
32608
33152
204761
52682
16602
171109
205983
189016
151648
5046
238148
1748
96002
76006
55690
224514
136312
148838
94901
103801
78863
33410
81183
115448
50915
3242
207678
176913
64793
83278
94525
82130
116737
206916
114406
84673
246977
173449
129299
80085
214230
5954...

result:

ok 299999 numbers

Test #31:

score: 20
Accepted
time: 926ms
memory: 103204kb

input:

299997 299997
190993 215622
243261 26985
127770 251331
111155 41690
101159 31069
29199 285927
140484 139072
135109 18256
146623 239470
158906 119232
241906 281104
263930 235599
80043 130803
265878 266345
77202 175920
289086 99035
140600 133644
169588 266548
230444 163562
94229 242491
56720 190479
18...

output:

290866
14937
13346
240114
4793
217485
129252
11210
189154
44538
249342
87105
250322
101710
188454
24352
131134
86431
82991
12889
232740
38
3237
150432
227843
33074
10172
147166
128156
7611
26151
27472
41580
3212
189958
186596
105636
3452
45187
183054
61073
41651
10288
45726
93600
140880
229014
27814...

result:

ok 299997 numbers

Test #32:

score: 20
Accepted
time: 899ms
memory: 100544kb

input:

300000 300000
148349 245555
245354 71011
149343 269464
242383 282469
148527 292294
42415 86272
13679 134550
212614 282776
233124 41381
146910 183006
137371 184324
224049 137290
234770 86628
228569 46338
218151 69152
24578 220200
106904 39810
264055 196329
13754 17665
288981 124549
259685 40701
28486...

output:

49781
296960
75532
229085
23875
75341
209
195487
138057
129109
154280
11922
15783
83877
223219
209219
113978
167906
175343
11182
71695
137117
241246
136477
110931
67885
4617
194285
128747
128736
260623
257512
62455
40155
14234
128411
137319
239092
46829
270200
39346
145983
59972
237948
2435
94043
17...

result:

ok 300000 numbers

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%