QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244096#6406. Stage Clearucup-team1198WA 16ms263248kbC++202.5kb2023-11-08 21:05:532024-08-15 21:08:07

Judging History

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

  • [2024-08-15 21:08:07]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:WA
  • 用时:16ms
  • 内存:263248kb
  • [2024-08-15 21:05:17]
  • hack成功,自动添加数据
  • (/hack/778)
  • [2023-11-08 21:05:53]
  • 评测
  • 测评结果:100
  • 用时:7ms
  • 内存:48316kb
  • [2023-11-08 21:05:53]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()


const int N1 = 40000003;
const int N2 = 41289407;

ll key[N2];
long long val[N2];

int pos(ll u) {
    int i = u % N1;

    while (key[i] != 0 && key[i] != u) ++i;
    return i;
}



const int MAXN = 36;
long long A[MAXN];
long long B[MAXN];
long long G[MAXN];
long long order[MAXN];
long long n;


long long get(long long mask, long long reachable) {
    
    int id = pos(mask);
    if (key[id] == mask)
        return val[id];
    key[id] = mask;

    if (reachable == ((1ll << n) - 1ll)) {
        long long cur_b = 0;
        long long mn = 0;
        for (int j = 0; j < n; ++j) {
            long long i = order[j];
            if (!(mask & (1ll << i))) {
                mn = min(mn, cur_b - A[i]);
                cur_b += B[i] - A[i];
            }
        }
        val[id] = mn;
        return mn;
    }

    long long res = -1e18;
    long long mn_pos = -1;
    for (long long i = 0; i < n; ++i) {
        if ((reachable & (1ll << i)) && !(mask & (1ll << i))) {
            if (A[i] >= B[i]) {
                long long new_reach = reachable | G[i];
                if (new_reach != reachable) {
                    long long tmp = min(-A[i], get(mask | (1ll << i), new_reach) - A[i] + B[i]);
                    res = max(res, tmp);
                }
            } else {
                if (mn_pos == -1 || A[i] < A[mn_pos])
                    mn_pos = i;
            }
        }
    }
    if (mn_pos != -1) {
        long long i = mn_pos;
        long long new_reach = reachable | G[i];
        long long tmp = min(-A[i], get(mask | (1ll << i), new_reach) - A[i] + B[i]);
        res = max(res, tmp);
    }
    val[id] = res;
    return res;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int m;
    cin >> n >> m;
    A[0] = 0;
    B[0] = 0;
    for (int i = 1; i < n; ++i) {
        cin >> A[i] >> B[i];
    }
    for (long long i = 0; i < n; ++i)
        G[i] = 1ll << i;
    for (int i = 0; i < m; ++i) {
        long long a, b;
        cin >> a >> b;
        G[a - 1] |= (1ll << (b - 1));
    }
    iota(order, order + n, 0);
    sort(order, order + n, [](int a, int b) {
        if (A[a] < B[a]) {
            if (A[b] < B[b])
                return A[a] < A[b];
            return true;
        }
        if (A[b] < B[b])
            return false;
        return B[a] > B[b];
    });
    long long kek = get(1ll, G[0]);
    cout << -kek << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3676kb

input:

4 4
4 2
5 3
2 6
1 2
1 3
2 4
3 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

15 14
254040392438309 117083115436273
500005748229691 557255157630172
821034233718230 865199673774998
659892147898798 987564141425694
81172575487567 811635577877255
751768357864605 341103322647288
454926350150218 140191090713900
921608121471585 659295670987251
223751724062143 505619245326640
8907765...

output:

1665396301509143

result:

ok 1 number(s): "1665396301509143"

Test #3:

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

input:

18 17
636830992776530 847574431876821
330869946457865 78274534165482
450581372553540 11565219334965
8736347226844 17186323694285
870805093198860 559070167736042
674369178493171 930151818400874
641605209598997 222521062460239
450936030349531 469197172169023
831295459816974 626096008793091
53095460351...

output:

2375957544280218

result:

ok 1 number(s): "2375957544280218"

Test #4:

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

input:

20 19
539893468691183 767805205447882
240338186903141 960937349402327
942645580569365 896509929612645
542601575005817 191461109090531
540992546866047 765080044816119
904535155855114 858111921213175
452499200048240 115895143306864
983856946412026 838504718536099
586421298181479 265212699386882
677124...

output:

800919806038419

result:

ok 1 number(s): "800919806038419"

Test #5:

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

input:

24 23
114281007218527 308690671179962
145951034437731 718976086594208
709172151907814 926071954787084
224496444610281 498657753059525
874422017133378 857676356343078
532175866197017 818525693672607
303837639402605 374469705563954
512244364294540 952911486867703
748959419417502 249992707230361
512696...

output:

114281007218527

result:

ok 1 number(s): "114281007218527"

Test #6:

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

input:

36 35
389328367777319 678636570542258
32216944647452 612585362150577
891592845704885 596030605892036
688825276167602 461516360471825
916552899998310 106733202183953
400050408958777 670724326933521
995792861502757 894514508573875
14511185222713 612305257166443
175168368096281 508263855969282
85578802...

output:

171942144116875

result:

ok 1 number(s): "171942144116875"

Test #7:

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

input:

36 35
759037289890767 849577210686635
16379509883489 441829377955433
589378488455351 990818352083122
871208015900506 727359003875494
207852561142533 28766987248469
81321183353129 892618157632070
198487099788393 519364502513651
83942803274015 988821788304459
868185445880277 269956013388079
3834515054...

output:

759037289890767

result:

ok 1 number(s): "759037289890767"

Test #8:

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

input:

36 35
100792831728257 823656493168793
866936535786311 187861146327778
132998929717538 605906559206892
3319598846477 393401056223733
964444786730964 932398059281618
925176496607384 148825907337833
985037559482190 646827297289525
469876125353024 641923164294854
453796287874442 291205025001534
72806942...

output:

1397699717661157

result:

ok 1 number(s): "1397699717661157"

Test #9:

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

input:

36 36
245996406159980 462974248377488
839352152971124 40282565369163
572695144110271 507726167903341
671102350267895 18090181781241
643724978558334 551787913319524
936340565446887 517649577919257
158127116487034 175750969611510
396852573858996 670814068366285
534702788102341 124550558279140
69441153...

output:

2508008255775889

result:

ok 1 number(s): "2508008255775889"

Test #10:

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

input:

34 38
656738239290510 319959252044415
760511943177376 828562698756504
470087249708484 441916827764162
105399930988058 761192720347117
81742549616394 195819875734286
782982110569406 72384154665629
647269989285797 720280547207448
531182311814386 160821851115134
292963780645658 871789628567253
74499577...

output:

656738239290510

result:

ok 1 number(s): "656738239290510"

Test #11:

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

input:

32 40
818105834607446 689904077664886
717146597564762 686987602224041
538827104521875 147060924732538
604913134601443 802546720879673
45376965619246 480061093729529
686039951678173 889398415870480
374408509732957 354006189233817
103818950629279 863526642478066
719174876808085 130061851080766
9744074...

output:

2289520618562758

result:

ok 1 number(s): "2289520618562758"

Test #12:

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

input:

30 42
730678486091139 762413502107242
564137648972911 492217680357057
677122869459914 634406715345550
766223620461328 750896882727596
34139073751269 875301336250330
948602995486093 589201509496124
333847023521138 673322700954330
774661538057122 360743409997856
301647343463502 78371781314140
44979585...

output:

2296677982487339

result:

ok 1 number(s): "2296677982487339"

Test #13:

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

input:

28 44
996216744822715 15265122654307
591377215147374 392892022614182
134817686923570 666778840251745
603108267679560 939679039946396
792878600465606 943254465658609
705582931165204 626247204621328
833947774992752 802610518921019
60510220659563 935537906466250
900509663884138 957082020010408
38517385...

output:

1021065751521024

result:

ok 1 number(s): "1021065751521024"

Test #14:

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

input:

27 45
271265179156100 385209948242010
548010795825703 286502371912374
203557541769729 336737491323929
32253800857105 902537647325928
835008409588714 227495683621084
573457473959732 478446911624066
447407603972649 401150715116732
597962487418392 594931676764990
326718612562917 293848561935121
6497688...

output:

271265179156100

result:

ok 1 number(s): "271265179156100"

Test #15:

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

input:

26 46
511128167626061 755154773895250
469460004382432 144928349121735
272299544034000 41881588292305
453271611317466 830211882616629
877138218711823 441367083696839
476515315035731 252150151731957
174547198161633 921197665643069
56919360991429 297636468095153
717743189152864 552120784448634
95767590...

output:

511128167626061

result:

ok 1 number(s): "511128167626061"

Test #16:

score: 0
Accepted
time: 6ms
memory: 26644kb

input:

25 47
483175861091928 628662160345159
414348784525954 991346283769736
118134342611258 254055400216860
367817156249062 195226919472367
228751017881407 501458690109441
595787759089619 364958390117603
758404493344385 423811540220990
373421064986368 503851495028044
645521325517401 846860937023068
696132...

output:

433844295661451

result:

ok 1 number(s): "433844295661451"

Test #17:

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

input:

24 48
585069488201283 197610097667134
308270082266799 808583330722288
557830556971222 120690636824478
35599907670481 819914971288051
829534742813930 120848544147347
606952901638178 768967506529684
782628839276718 874238745648127
300397513492341 497558026945107
804922145123731 680206470300674
6976592...

output:

308270082266799

result:

ok 1 number(s): "308270082266799"

Test #18:

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

input:

22 50
263626616368674 621403432100399
205992448402675 530375039808909
713311017185345 512666135865696
98177241911216 239357547305336
958069323825513 67526585039598
167011099703449 27907032353436
450240530654192 706870876965792
690862186234915 405560181003741
18305076367979 434288631592058
2040128611...

output:

205992448402675

result:

ok 1 number(s): "205992448402675"

Test #19:

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

input:

20 52
975090006577788 801607726815766
84021986863902 176019568163775
33212494351022 557726461236616
412670490881035 171242243090013
5963358074583 814694975209648
727321559408120 470824240668916
517979548077593 380688272528419
111042754309162 470362460253753
261749697831900 173917705785526
7629533862...

output:

84021986863902

result:

ok 1 number(s): "84021986863902"

Test #20:

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

input:

18 54
189279872302549 253462459097101
970052803238801 70690425994748
748182832410340 900454936920101
461133559455077 21855992163077
331483449573694 323350930734446
706088561801647 138174738356485
393662591863692 483667366492868
786416692433338 336160844825462
593801741696439 741382094229566
74860376...

output:

3169539405883373

result:

ok 1 number(s): "3169539405883373"

Test #21:

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

input:

16 56
395342015310127 775685935556101
934577939024901 965361283792952
576834009420570 129503647328961
544782073827006 837284295438253
727371211508645 718326047275565
641544543098215 727030916600087
304530007771390 508152141046117
496976076388171 88278390380724
847359466084241 230351089520581
3857288...

output:

1347938772919751

result:

ok 1 number(s): "1347938772919751"

Test #22:

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

input:

13 59
462049122847001 379819318643195
906994629984306 817782702834337
16530223780534 109817575436611
212564825248425 461973420995760
441834701715792 337715901313471
617525313590710 209535426197959
442435192654635 37074739626278
388768152805311 117169294452155
41944657812171 28512250709355
3872542920...

output:

119277473592348

result:

ok 1 number(s): "119277473592348"

Test #23:

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

input:

32 40
378399574707502 124158745794613
757495231509323 219929822776362
23848097920043 150433648754718
89027690774330 779645256050635
561907039859750 609241299826157
763643565846881 888507632657093
676333558739618 640176398893719
71406433730404 424845408152620
798830911154534 473380124569425
633777571...

output:

822140162613756

result:

ok 1 number(s): "822140162613756"

Test #24:

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

input:

30 42
727583199647302 899249515493018
824090068816978 76007172563392
363024240077233 850438221628153
116359591692923 853281819729394
30058530056444 451301982541902
257660265949748 13377896646178
663971991464535 131134512531065
157395062362446 37580106788817
319094964254516 820617709636764
1504315319...

output:

501974519873235

result:

ok 1 number(s): "501974519873235"

Test #25:

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

input:

30 42
369260360694270 102056318890914
748491825980791 78813132950858
954070327995137 432356970729848
350635553708712 691146527864719
294293282115372 475494513261924
888038522270337 103810618966978
113783109472848 809679509781223
837753634194548 568343084457732
919145501514622 341839377646785
5331973...

output:

1549961271972830

result:

ok 1 number(s): "1549961271972830"

Test #26:

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

input:

27 45
819114038925000 120254131272485
104179695468842 921918040684848
746447605230839 27295948036099
986064794301025 488949445854444
234655178368316 80833846135201
919985230880643 628120598515383
196387855735763 424772227837484
131469466148846 89448230360542
403974409238330 13826215541265
6944769649...

output:

819114038925000

result:

ok 1 number(s): "819114038925000"

Test #27:

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

input:

27 45
486496070101292 615597109349036
242572807341486 639449514382537
377052935256294 551281267552890
40515117640598 407260163013031
405708189500053 766515180186126
483209839402832 362312036386239
532925852053573 493806909782433
696724944982406 733419216410091
60505679723836 533368236070572
11723652...

output:

242572807341486

result:

ok 1 number(s): "242572807341486"

Test #28:

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

input:

26 46
453718434413073 553397640961890
150619756399004 630260113021239
420562810047600 640552759162041
13296127747875 632471460306683
77074282416426 729821456755890
716966018482019 933374142866615
788537379821196 337442301680265
592445203074505 472078597445832
688056655927586 685777876573115
93009595...

output:

150619756399004

result:

ok 1 number(s): "150619756399004"

Test #29:

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

input:

26 46
58175650161464 42271857470481
470798493732803 957941605443488
422744095940059 108786907923757
956120077112935 880056937358567
141334402731044 765692212925074
281492906357796 931625701488132
873804234821197 229067678553001
381876791746006 492332722216193
812525232730573 209319517737245
13596589...

output:

58175650161464

result:

ok 1 number(s): "58175650161464"

Test #30:

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

input:

25 47
828420043451914 23238564513072
697852262104269 282962592679943
11641622610262 875935569794851
700951527948597 388158600069851
670930822274257 412137048360986
620516084451297 398117269577950
141395806409204 787408902235324
486108629647082 495272150546778
600334776708984 977561962353395
20865789...

output:

1237959652558927

result:

ok 1 number(s): "1237959652558927"

Test #31:

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

input:

25 47
899428122989338 145899041295597
222881474387355 567396721892960
575835915985374 936155770553948
827654190821346 987307978499644
718341345091272 127093962829633
986836218775381 333226666595599
304220802797171 857497097818156
808973011582896 646782097895557
468853452093373 995220967981033
673952...

output:

222881474387355

result:

ok 1 number(s): "222881474387355"

Test #32:

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

input:

20 52
632260641570555 458297297435212
811156594450074 396457920718786
828263304935855 598595529361630
494991655931244 565522700362647
637615228409302 53103708098168
282478952695367 559572457996575
283996296745450 136755148534977
311987900253249 916264279266468
127568654657954 419757804830372
1708998...

output:

1857245089696723

result:

ok 1 number(s): "1857245089696723"

Test #33:

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

input:

15 57
246045112915803 655156218208647
705418683694813 693501915791545
566584169060430 510070696716134
250578771535460 225895985907743
333447992843769 890301019152478
84932311613578 109581086444286
661795095725753 737789845693119
701638652385996 314265702790340
193866121765676 448306478072597
9012598...

output:

605304227530846

result:

ok 1 number(s): "605304227530846"

Test #34:

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

input:

13 59
693204042546316 810185778594521
577525994704226 715733166899945
143330503316974 422966459358241
971725930037503 176570841054548
86003143095734 958285835119465
1598110351366 843161843630556
864558845987130 616058236912443
616184515207279 183019603196329
538466547766038 827543523288927
308731090...

output:

1598110351366

result:

ok 1 number(s): "1598110351366"

Test #35:

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

input:

12 60
686900984655521 360414706539893
564707323239259 156422972125429
177275901374697 340280191229025
353147113772471 696217870144290
232816449731091 475738298171206
379431990659762 331837831277566
271071520158508 717200993828896
442174414532731 64467307038885
556024119489408 326171436618540
9234337...

output:

303548940354760

result:

ok 1 number(s): "303548940354760"

Test #36:

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

input:

29 42
775040437393962 341248169572722
986673473366420 634123558200586
924986853178078 748471027022825
220163146224574 731581874814033
385709535495598 952817310574349
68544084339822 938274652091880
915849278438528 969841130480180
882948261552555 194219121621828
680383071366521 407035944045810
1242317...

output:

1613126307696715

result:

ok 1 number(s): "1613126307696715"

Test #37:

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

input:

29 42
280442758337323 964044615740258
856866854977356 428408249755903
451422599196949 450802876808564
486192252911295 812853895201934
151394499276980 305012731719696
693398562780693 713840288945199
994225486768439 619173751456789
662938189816865 358038644211298
670267820893456 657698170464678
255707...

output:

98218787477468

result:

ok 1 number(s): "98218787477468"

Test #38:

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

input:

29 42
813796312105760 783703493344605
825483551250787 411458305042996
210518939857124 940960914571445
802491442577588 721287110936336
486970196961161 597114398936025
277475990353469 455092006856839
602426312673869 922882210485238
91242041997403 429325052593381
732377655248557 535122703672441
7524076...

output:

91242041997403

result:

ok 1 number(s): "91242041997403"

Test #39:

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

input:

18 45
594247067382505 846814583019333
695621534604244 985672506912825
805694540689387 313251415429368
532850454497918 765416664994713
181104130849203 198365592245958
805389383644932 82856277036608
443127561088956 170757175173976
408684236987774 331033738634615
183655725543102 44056078830231
37396744...

output:

1854803359120378

result:

ok 1 number(s): "1854803359120378"

Test #40:

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

input:

18 45
869295501683122 216758334865213
652256188991629 879281782469194
909620915108026 939897971728304
918684966644039 728275272407013
223235013714136 447422438119601
673262852664867 935054910264754
91771762124917 725987424014553
867640036818987 955242063037163
609865747963705 267141781771265
6033780...

output:

652256188991629

result:

ok 1 number(s): "652256188991629"

Test #41:

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

input:

20 51
850852297008974 136990182210865
526540057315305 726761299391799
366501824744074 789658309917152
531044513801444 902550057803260
928606839470155 618247943078078
824933436873786 898200458907711
902665752574159 654544803208186
400560952881482 438229374678863
364992660102802 906259546106881
635869...

output:

366501824744074

result:

ok 1 number(s): "366501824744074"

Test #42:

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

input:

20 51
211052117262437 190837617314603
502812141185395 554944806663875
418056984281381 590171624682730
50795475880954 359132952666421
944642867180966 351052436410927
473807144822162 226445958317525
843137849729881 853450218823195
253573358897996 686837758438758
116981196837615 323575165473552
9128115...

output:

211052117262437

result:

ok 1 number(s): "211052117262437"

Test #43:

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

input:

20 51
813390888614857 858217844080423
463537282351056 536934353385419
452427448575373 442742062537798
782961502239583 379809952932699
961644984109369 418741513614116
982175411110178 152546885544335
189114387054517 652721927501019
543955539680419 481350808402976
386925553797932 48798319024068
8029399...

output:

2241571410196649

result:

ok 1 number(s): "2241571410196649"

Test #44:

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

input:

22 40
155146430452348 867481498618645
357403181834422 212596303838277
996047889870328 14520322339199
915073085218322 2540984216747
683052837608968 322371511905442
826030724364433 452064582572466
940480474692250 701690402865693
929888861726660 99266738529946
937352023768802 105230629017299
3897264743...

output:

2165047081298470

result:

ok 1 number(s): "2165047081298470"

Test #45:

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

input:

23 42
231364787300087 588708086746379
294400406804638 101263677243097
195653278943483 553925383492581
245485466842253 479800879411722
716090982280949 166176103505671
912905028197752 671225563411201
297297853350273 656556506061566
994788055405340 212755842689899
959285991205755 169274008814231
720471...

output:

3777510754010355

result:

ok 1 number(s): "3777510754010355"

Test #46:

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

input:

24 44
175460174231822 265351968083189
184176893317089 758915174417499
773645258241486 978274081149051
31266609284773 52841240526208
419317654329174 137495179000186
221816512966775 888716464916189
429825924110530 618474307895041
671101410750355 738865661732000
736345797039982 802066408769115
16220258...

output:

175460174231822

result:

ok 1 number(s): "175460174231822"

Test #47:

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

input:

24 44
708813727967491 85010845687536
74298196437495 741966303446415
454245132006813 468431045202875
461244490451098 847592543502338
754893352013355 429597919991107
727398547353759 629968182860597
38025676306904 808503001648865
134589635019726 696470157388579
833638929774859 714676387807533
737397350...

output:

1215929729344722

result:

ok 1 number(s): "1215929729344722"

Test #48:

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

input:

25 46
60080519148615 176183333177565
46425468980888 410563187165748
722591449635183 677793683719385
177491384188382 287711046044077
830061305841213 557642655811988
603652000795814 701327796960247
51614978750839 361911448556867
736941095358931 477479680757096
246597473801760 80300863698523
3408635072...

output:

46425468980888

result:

ok 1 number(s): "46425468980888"

Test #49:

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

input:

25 46
593434072884284 995843284523737
936545698359470 358428870364009
438376769198397 167951721515034
458605128056788 196143188036655
130452631436562 920114140947805
222913800457421 442579514839119
581320411503245 551940142310691
200429319628301 470270696018923
343890606536637 957726470648109
916059...

output:

593434072884284

result:

ok 1 number(s): "593434072884284"

Test #50:

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

input:

25 46
101113430165697 897410995047123
948236174411391 299230560603337
843701445588082 252383116961599
394224000570457 800155313295116
863099450513195 358135152606202
760893975064973 34168543008071
373247985320029 360086425366052
837024661093675 669465251779129
347026834424506 144344243528222
7852878...

output:

2429245279767893

result:

ok 1 number(s): "2429245279767893"

Test #51:

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

input:

26 46
330402009473496 249937889483976
61345132871274 379275200647275
938773345466421 696022292976167
159071519490956 519691077593980
527933372379465 137900164414770
690922430113097 244064388967891
266265544121578 721196095531055
930237124789652 487808342452694
749990226125613 129921843192225
1973741...

output:

2738903040336365

result:

ok 1 number(s): "2738903040336365"

Test #52:

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

input:

26 46
975158292178504 790824428990648
966960127856744 137312864097332
783795309925126 760768690239438
727287697628157 713206882579293
975042607921420 265679774255969
318564214196824 204477087685499
117603983443175 901275264569584
423440170583334 567030738695466
834031880466788 114700777261112
872728...

output:

2460098374349460

result:

ok 1 number(s): "2460098374349460"

Test #53:

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

input:

26 46
508511845946941 610483306562228
935575750388351 85179621037417
578073875157716 250925654326030
43586887261682 543144705160671
275435007258593 557782515279658
824146248616575 980913177718739
690620437292541 204983723565265
922112766908768 559819606440878
931325013168897 956942012089098
41274014...

output:

179586106473921

result:

ok 1 number(s): "179586106473921"

Test #54:

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

input:

36 36
265390324840522 981391526521679
59755335485787 560614258236702
858771905281187 586301373791191
525390894918919 834201926923069
963139736974738 740621823191032
145220624780272 422821531879956
793054482737908 853608109520767
582304204524819 112786292125327
398947287545574 784658996613241
5868615...

output:

59755335485787

result:

ok 1 number(s): "59755335485787"

Test #55:

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

input:

36 36
306423235824837 702619188424004
961567114658114 449281631641523
979882974943142 239386200186429
812492255445890 311462895794333
996177881646719 505929947896414
267279300702424 641981438976867
114687489339866 773288766918752
725698791356523 191091024163679
385696882926464 848701302701117
882420...

output:

583687022343975

result:

ok 1 number(s): "583687022343975"

Test #56:

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

input:

36 36
770792645783883 604187972689215
973259738160915 390083321880851
385207651300059 288633223544162
791420001572872 993970414205818
693639254892696 14320777441531
883754868462999 198386095056986
906616136898475 502941804271969
440788452233097 425469952012716
345522089750140 35320149257518
75165011...

output:

4007685041883699

result:

ok 1 number(s): "4007685041883699"

Test #57:

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

input:

36 36
3 4
7 7
9 6
876680932998017 897839560302902
572881571507850 577202589448494
953856943022759 989765778855270
897839560302902 904375790039373
848880482878050 876680932998017
577202589448494 641067493891000
117146848445101 124202533407936
989765778855270 996863378865083
998633100404696 1000000000...

output:

23645423995458

result:

ok 1 number(s): "23645423995458"

Test #58:

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

input:

36 36
2 9
1 5
6 1
801137072250929 836419312424703
345010389109738 369836736859468
836419312424703 883576736875016
972460325208472 978666882290059
560164931958050 586449345931697
208328815630156 232085702062050
681084334607525 688831143202755
883576736875016 972460325208472
674810708829848 6810843346...

output:

86345315185140

result:

ok 1 number(s): "86345315185140"

Test #59:

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

input:

36 36
1 1
6 8
4 10
844012573893511 871007285165176
727058509559764 740386302772830
357811504028775 368530736787568
690925176024113 704962935895143
464227592193233 529475640438910
459408820770528 464227592193233
894442534808484 903989836254421
276998730370972 357811504028775
983030074666336 985685416...

output:

5365160898014

result:

ok 1 number(s): "5365160898014"

Test #60:

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

input:

20 51
357451582777216 997904818117754
140470316932369 162838043478121
74603851558269 115270511619778
149935332201362 357451582777216
183342126309039 242992837079353
162838043478121 170973778094011
432963271512564 507260347364889
170973778094011 183342126309039
518466337486082 551651707458793
9979048...

output:

99803656870860

result:

ok 1 number(s): "99803656870860"

Test #61:

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

input:

20 51
193405974300400 51677996520731
96899418770542 106986733377212
193658078621940 256887288792041
256887288792041 261971698431788
261971698431788 342655415551794
438650290771626 474222355458260
625414187061339 673806165892941
474222355458260 575781664430106
342655415551794 438650290771626
72703695...

output:

235164852769746

result:

ok 1 number(s): "235164852769746"

Test #62:

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

input:

20 51
147628302403879 188126787409101
188126787409101 28301431814293
110934405626363 124182236868774
28301431814293 39235483361939
322823841461225 358796731942554
289624984221841 322823841461225
358796731942554 382683283696034
722607278447022 802144279574888
802144279574888 821414098447368
903080364...

output:

224944616426562

result:

ok 1 number(s): "224944616426562"

Test #63:

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

input:

23 42
452820142154732 502106831971632
502106831971632 102491707512693
102491707512693 111451875792058
462017547243623 452820142154732
111451875792058 191780217291648
267235792647203 273048719461706
373756303379246 467800594958165
203457139684630 267235792647203
191780217291648 203457139684630
273048...

output:

452820142154732

result:

ok 1 number(s): "452820142154732"

Test #64:

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

input:

23 42
686911003534861 556257620660154
55329199661291 178769883663780
556257620660154 55329199661291
204364844436002 225238303156938
110892328966590 686911003534861
225238303156938 237753318502064
178769883663780 204364844436002
299305015208078 301122210165749
237753318502064 299305015208078
63005506...

output:

80924160433513

result:

ok 1 number(s): "80924160433513"

Test #65:

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

input:

24 44
113958433735448 156041739334674
91963777859270 115638289342413
115638289342413 150208369484374
150208369484374 188513767651778
211772940362015 240291595560574
244778960583906 296304051428844
296304051428844 387782675836989
387782675836989 430562871290388
430562871290388 437440035945106
2402915...

output:

116505852413860

result:

ok 1 number(s): "116505852413860"

Test #66:

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

input:

24 44
991334731479676 740178845280853
48625596663952 73187661695119
76254041735907 197078280440967
197078280440967 205360210401866
192702187136272 991334731479676
205360210401866 288991289989795
740178845280853 48625596663952
349393343527515 364167433669972
288991289989795 349393343527515
3641674336...

output:

51691976704740

result:

ok 1 number(s): "51691976704740"

Test #67:

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

input:

25 46
648223131466768 794894168464622
968146390830673 648223131466768
794894168464622 2277682231567
2277682231567 21495088710685
21495088710685 86793450376374
86793450376374 127349301410574
197810132795110 301470225685954
301470225685954 351109775443404
351109775443404 355015492984716
35501549298471...

output:

648223131466768

result:

ok 1 number(s): "648223131466768"

Test #68:

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

input:

25 46
983753369813681 148323882938382
291193271779992 16956197044704
148323882938382 291193271779992
70502444501445 144378890334606
242310457337899 269128037045913
269128037045913 329331111947391
144378890334606 242310457337899
58810868773094 70502444501445
467812526809518 527222944638238
5272229446...

output:

348684511840509

result:

ok 1 number(s): "348684511840509"

Extra Test:

score: -3
Extra Test Failed : Wrong Answer on 1
time: 0ms
memory: 3676kb

input:

5 4
2 2
6 5
10 7
2 2
1 2
2 3
2 4
3 5

output:

11

result:

wrong answer 1st numbers differ - expected: '10', found: '11'