QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#839853#4. Gapkhoaduy30 31ms7040kbC++14972b2025-01-02 10:58:152025-01-02 10:58:15

Judging History

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

  • [2025-01-02 10:58:15]
  • 评测
  • 测评结果:30
  • 用时:31ms
  • 内存:7040kb
  • [2025-01-02 10:58:15]
  • 提交

answer

#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int n)
{
    long long limit=1e18;
    if(T==1){
        long long a[n+1];
        MinMax(0LL,limit,&a[1],&a[n]);
        int i=1,j=n;
        while(j-i>=2){
            MinMax(a[i]+1,a[j]-1,&a[i+1],&a[j-1]);
            i++,j--;
        }
        long long ans=0;
        for(int i=1;i<=n-1;i++){
            ans=max(ans,a[i+1]-a[i]);
        }
        return ans;
    }
    else{
        long long ans=0;
        long long curr=-1,idx=-1;
        long long lim;
        int cnt=0;
        MinMax(0,limit,&curr,&lim);
        while(idx<60&&curr<lim){
            long long mn,mx;
            idx++;
            cnt++;
            MinMax(curr+1,curr+(1LL<<idx),&mn,&mx);
            if(mn!=-1){
                ans=max(ans,mn-curr);
                curr=mx;
                idx--;
            }
        }
        return ans;
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

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

input:

1 2
29659227736649406 728704890713443211

output:

699045662976793805
1

result:

points 1 M = 1

Test #2:

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

input:

1 15
4910834401530995 82366510858893943 154224513006215114 167111470747458922 291518420333647381 360708376904159067 475438451423179257 514521822479974099 544779904916816505 631359818684602077 636047253191505154 815280682985156693 908104066692014481 977273719899584711 997330329109444588

output:

179233429793651539
8

result:

points 1 M = 8

Test #3:

score: 30
Accepted
time: 1ms
memory: 5848kb

input:

1 15
26822012613602297 83016336616322262 240236403235204784 251263501103080046 267418872581278273 283465011506182121 387188614324429897 405999856871910796 621222868183510412 705139383465288123 737738410068055892 825642738416654428 854722383986606367 855077944176184296 908358416490444978

output:

215223011311599616
8

result:

points 1 M = 8

Test #4:

score: 30
Accepted
time: 1ms
memory: 5820kb

input:

1 15
9924552505919890 20650946047777351 137465276238229613 316776581684046368 328799260840899945 352871104748474083 461843498111917783 467004768858109370 483649564461099301 522358288815328209 604961424367736207 741995299386981061 796141495301995014 806409479876611358 985852922191990473

output:

179443442315379115
8

result:

points 1 M = 8

Test #5:

score: 30
Accepted
time: 1ms
memory: 5804kb

input:

1 15
5829742 7847985 9866228 11884471 13902714 15920957 17939200 19957443 21975686 23993929 26012172 28030415 30048658 32066901 34085144

output:

2018243
8

result:

points 1 M = 8

Test #6:

score: 30
Accepted
time: 1ms
memory: 5860kb

input:

1 100
3343298378001251 17484402436127123 23692744930918786 26627871378097607 27094733652649548 36364042508477388 38440289626273354 51568172689743427 59547297792096252 69378457790067663 90898643112854066 126667262868037819 128409326258917243 151146480509633563 160238662778949922 169891116525178350 17...

output:

51057453672116406
50

result:

points 1 M = 50

Test #7:

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

input:

1 100
6615965004180765 13185207460451761 23734307750252029 24158382668441223 49162776469681165 50213865766220511 56584679171324873 72355935174261200 78534230832420118 86100851851862565 89979985531351472 98750915670727392 109538473420377753 110428987732941952 111325085136921829 114262413730167727 118...

output:

49328838642377492
50

result:

points 1 M = 50

Test #8:

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

input:

1 100
709357564623321 7712824696571068 24393851130421107 27005556867201291 28185446351046950 59253483486983895 66103734017093545 90874504779503203 94536894293511165 101066291988100224 132440848420581011 136611074783604734 139508009804041082 146397349745117579 155563877383458473 182718838546797030 19...

output:

44115425462423692
50

result:

points 1 M = 50

Test #9:

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

input:

1 100
14237546663715875 26898867314446811 32923852684187028 35501560148931192 42094588678535703 46313954319267128 46780297957478675 54140230845661659 69717122031105868 85227834377828719 87123433354912852 87694208848816839 100294949511635763 100640491384053889 117783048175404598 120498517471861537 12...

output:

45345737967249636
50

result:

points 1 M = 50

Test #10:

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

input:

1 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 482771 482772 482773 482774 482775 482776 482777 482778 482779 482780 482781 482782 482783 482784 482785 482786 482787 482788 482789 482790 482791 482792 482793 482794 965533 965534 965535 965536 965537 9...

output:

482739
50

result:

points 1 M = 50

Test #11:

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

input:

1 1500
393226341882178 1321649646861936 1364933587797097 1889765428846896 2456116238504757 2518733965088369 3825795947577367 5405580152527417 5570252473787754 6350713065107462 6581444896242136 6656726663294586 8363165203490333 9558500171039813 9586690516318136 9673890229897646 12861707206480546 1294...

output:

5607705563272188
750

result:

points 1 M = 750

Test #12:

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

input:

1 1500
276387254568267 348298566021308 1125215387592508 1923588239039903 2955434210783111 3356563093662062 3954646930267164 4075124529772830 5324942771348103 6615468346955442 6997348010487097 7438352604440139 8115335024997761 8684463607233403 8919700770029490 9110179826351266 9192758850283477 974192...

output:

5550787805329272
750

result:

points 1 M = 750

Test #13:

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

input:

1 1500
394502620394491 477595652087208 1780588042371800 2567382279231585 3433538158427605 5126964998146432 5540015402387536 5863708707865343 7204628472359887 7409780941504842 7460021205004392 7947558620073481 8773299171413406 8907935113700215 9502489274784574 9828824230085381 10250737830740541 10348...

output:

5773483938914314
750

result:

points 1 M = 750

Test #14:

score: 30
Accepted
time: 1ms
memory: 3764kb

input:

1 1500
232644703989174 914925623772208 1780788508756344 1942956344014084 1951540326583367 2705677420197432 3315127930499324 3530924082453323 4063095195421877 5878910158522313 6191425649884323 7474281913739540 8005162170319151 9689629284273377 10553282724580534 11302266974886461 11328427098980173 131...

output:

5130685060193677
750

result:

points 1 M = 750

Test #15:

score: 30
Accepted
time: 1ms
memory: 3972kb

input:

1 1500
5829742 7847985 9866228 11884471 13902714 15920957 17939200 19957443 21975686 23993929 26012172 28030415 30048658 32066901 34085144 36103387 38121630 40139873 42158116 44176359 46194602 48212845 50231088 52249331 54267574 56285817 58304060 60322303 62340546 64358789 66377032 68395275 70413518...

output:

2018243
750

result:

points 1 M = 750

Test #16:

score: 30
Accepted
time: 4ms
memory: 6228kb

input:

1 25000
9133780858698 37909498824529 46424274433061 70160050989590 125416618927966 131263384497746 138567320950042 147982747026601 169954574711772 416414702693488 521633254355739 604620659815966 630248301432581 636599651288513 649591523233109 673879027226892 743167222805134 1050284364947427 10667909...

output:

400443289050740
12500

result:

points 1 M = 12500

Test #17:

score: 30
Accepted
time: 8ms
memory: 6092kb

input:

1 25000
95371433023390 183850194127179 204901134589572 252754062343800 256294085315900 272877283746967 359297770213316 362185632533591 367274595807277 538035954679833 574635344070507 592259524690062 732544214561464 736176455194807 747090611983790 751067222940691 764188551907236 792924484902295 86134...

output:

505979566183486
12500

result:

points 1 M = 12500

Test #18:

score: 30
Accepted
time: 8ms
memory: 6280kb

input:

1 25000
7504645895952 60172453317399 82471651467385 101821286783379 128772758422292 142128421583576 176046308040656 189670285914911 195166891755926 332153022335956 337772092961783 445143919770092 471801980403459 521901385689244 557011875311943 657204669416734 693608324078908 720572981724339 72166032...

output:

509260497524918
12500

result:

points 1 M = 12500

Test #19:

score: 30
Accepted
time: 8ms
memory: 6276kb

input:

1 25000
39499604978204 102114332324801 160517211313931 188637308000017 238002860728363 287351974543450 335961801282777 396999481527880 415187881071623 450041544343299 462992172994970 499000116280155 510734447770100 522124078388134 558759362727955 583635064368750 586330026742164 637440358336379 68038...

output:

476196269160204
12500

result:

points 1 M = 12500

Test #20:

score: 30
Accepted
time: 6ms
memory: 4196kb

input:

1 25000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

482739
12500

result:

points 1 M = 12500

Test #21:

score: 30
Accepted
time: 31ms
memory: 6956kb

input:

1 100000
4488179349610 16973330836139 44660350011287 46649694101657 54515631864687 62626048878225 77067984967371 77638306380215 86736649958265 106182394950493 109712006055182 112079135090560 120631618256852 131475831109715 132583034287859 147254369707135 149714669535946 158044969527118 1703406482415...

output:

113609171549866
50000

result:

points 1 M = 50000

Test #22:

score: 30
Accepted
time: 27ms
memory: 5452kb

input:

1 100000
13149709307416 18293717155215 25043623630885 44879400902614 49407376018350 52861802361795 53857880880850 58694832631466 63622284751967 66208436709721 73862222390267 79620705266666 94876232845299 132331415691214 153768757924367 164956420682250 180021859691119 182562169198074 188033608246735 ...

output:

127809210425414
50000

result:

points 1 M = 50000

Test #23:

score: 30
Accepted
time: 27ms
memory: 5368kb

input:

1 100000
5111699493996 19396274992433 20967237804327 32517505001678 37420536389187 42062575012054 52881565873541 55473734871126 96464144900326 102867496482900 108570627831112 121793007313548 125311330574962 133276275768191 148249097647989 152433525451301 152869309246267 153620613141705 1980527029859...

output:

145636692074772
50000

result:

points 1 M = 50000

Test #24:

score: 30
Accepted
time: 31ms
memory: 5372kb

input:

1 100000
12448126808805 14955287440308 18957486171700 26205108342440 35429821492473 37014077981695 37057923771744 56479710514435 74696614009460 79512505727286 81392393692907 83937107044022 86860753091654 90757682139231 97943450459170 100413143098496 104905348694766 111192555705468 137528216217108 14...

output:

124782173142764
50000

result:

points 1 M = 50000

Test #25:

score: 30
Accepted
time: 21ms
memory: 6988kb

input:

1 100000
5829742 7847985 9866228 11884471 13902714 15920957 17939200 19957443 21975686 23993929 26012172 28030415 30048658 32066901 34085144 36103387 38121630 40139873 42158116 44176359 46194602 48212845 50231088 52249331 54267574 56285817 58304060 60322303 62340546 64358789 66377032 68395275 704135...

output:

2018243
50000

result:

points 1 M = 50000

Test #26:

score: 30
Accepted
time: 27ms
memory: 7040kb

input:

1 100000
15609355723226 28246203120916 30534297616421 30860828332767 39610757317274 51747678705316 59431565063656 65334112957168 73755518304209 73983782735249 85678154678498 88615327621076 119910216575517 135696757222159 146948840815723 153918026203480 154953312049266 198110592039235 208594061499708...

output:

118147358961195
50000

result:

points 1 M = 50000

Test #27:

score: 30
Accepted
time: 31ms
memory: 5360kb

input:

1 100000
10126035265316 18812438778817 21939562196718 34894638833527 38854235463395 40111115712840 42519043571969 43016952934044 69976845297204 72056983241149 92536484920211 103356244768685 120903354118841 144620368621389 156984924786619 157738788406302 157904138655286 165482438928337 16686535822451...

output:

131778553155869
50000

result:

points 1 M = 50000

Test #28:

score: 30
Accepted
time: 31ms
memory: 5312kb

input:

1 100000
5196984998043 10787031331530 50135404987503 54792304198458 77983401426640 83070904825088 118151991355567 119230477408462 132306550794169 134404059623264 151597039637359 160097671531535 163732034708578 189765789913722 195170548694892 205393730407830 207208693338456 213544197686227 2144304840...

output:

125388883971902
50000

result:

points 1 M = 50000

Test #29:

score: 30
Accepted
time: 31ms
memory: 5376kb

input:

1 100000
19821024745776 35883956869682 37055128006390 73846930057178 74584703826867 75294939571297 79182722559431 79785889433372 82670507176415 106089250957212 112890558692026 127521606324433 174230033489231 177420213949701 184639822084732 195957538680526 209919488393415 209969657281950 213974569728...

output:

128742514930586
50000

result:

points 1 M = 50000

Test #30:

score: 30
Accepted
time: 19ms
memory: 6940kb

input:

1 100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

482739
50000

result:

points 1 M = 50000

Test #31:

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

input:

1 118
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 62 68 81 108 163 273 494 937 1824 3599 7151 14255 28465 56886 113728 227414 454787 909533 1819027 3638015 7275993 14551950 ...

output:

500000000000000000
59

result:

points 1 M = 59

Test #32:

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

input:

1 118
1 500000000000000001 750000000000000000 874999999999999999 937499999999999998 968749999999999997 984374999999999996 992187499999999995 996093749999999994 998046874999999993 999023437499999992 999511718749999991 999755859374999990 999877929687499989 999938964843749988 999969482421874987 9999847...

output:

500000000000000000
59

result:

points 1 M = 59

Subtask #2:

score: 0
Wrong Answer

Test #33:

score: 12.6461
Acceptable Answer
time: 0ms
memory: 3720kb

input:

2 2
78103569500113815 605712887753065418

output:

527609318252951603
64

result:

points 0.1806579280 M = 64

Test #34:

score: 35.6447
Acceptable Answer
time: 1ms
memory: 5792kb

input:

2 15
61436558421029682 83429206007963488 214541359837684412 243514252712970384 305484811504551902 336434369562156870 338340290496962958 497057755642276106 550273649621370145 553677540845214422 598379388791730666 658501786507934652 711557595985663747 814649872154415032 878126866231709433

output:

158717465145313148
93

result:

points 0.50920943410 M = 93

Test #35:

score: 35.1285
Acceptable Answer
time: 0ms
memory: 3848kb

input:

2 15
59675445208809451 142100938168130731 142778750537911268 145878063040919916 228454814846027076 365849136864612457 425894246981391798 451929789636893609 579288599904950343 611917505913569401 621800386060296794 637514454221919688 778985075063038449 874668678652079318 889214302684617492

output:

141470620841118761
95

result:

points 0.5018363190 M = 95

Test #36:

score: 35.1285
Acceptable Answer
time: 0ms
memory: 5872kb

input:

2 15
57755783461204076 72549946137614447 179385293992102048 209990359510105993 301191691762496670 410470902706229658 430983119114331844 467619140342868405 748689830575686738 753404177880679738 837146843904735841 854384575303601726 891183470551146115 892712248087677608 971404558488464135

output:

281070690232818333
95

result:

points 0.5018363190 M = 95

Test #37:

score: 45.8225
Acceptable Answer
time: 0ms
memory: 3836kb

input:

2 15
5829742 7847985 9866228 11884471 13902714 15920957 17939200 19957443 21975686 23993929 26012172 28030415 30048658 32066901 34085144

output:

2018243
65

result:

points 0.65460680640 M = 65

Test #38:

score: 70
Accepted
time: 1ms
memory: 5860kb

input:

2 100
4935323238097746 28534213362222140 37905204271928606 44835155959615084 46421753700280925 48315957519843128 62269291292786035 63677966833361016 66226051078537021 79200319592861218 92073281359962070 94698585949845662 96212735984345494 101730013130158889 108346369730603809 112048482398636871 1158...

output:

54067555940387079
278

result:

points 1.0 M = 278

Test #39:

score: 0
Wrong Answer
time: 0ms
memory: 3812kb

input:

2 100
329840134021571 3524716673488504 14138718779423773 18864428727339342 46450227836078195 48967880893262489 56068731734091538 81008716200191803 87755612255127591 99979863565778359 103237562738020533 121702606144800766 133561647213804519 134821681550500923 171577745967038556 205671541794608303 216...

output:

36756064416537633
275

result:

wrong answer returned 36756064416537633 but expected 59713872839546348