QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197652#4. GapCamillus#12.886307 57ms11028kbC++202.0kb2023-10-02 18:04:582024-07-04 02:49:18

Judging History

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

  • [2024-07-04 02:49:18]
  • 评测
  • 测评结果:12.886307
  • 用时:57ms
  • 内存:11028kb
  • [2023-10-02 18:04:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#include "gap.h"
#else
static void my_assert(int k){ if (!k) exit(1); }

static int subtask_num, N;
static long long A[100001];
static long long call_count;

long long findGap(int t, int n);

void MinMax(long long s, long long t, long long *mn, long long *mx)
{
	int lo = 1, hi = N, left = N+1, right = 0;
	my_assert(s <= t && mn != NULL && mx != NULL);
	while (lo <= hi){
		int mid = (lo+hi)>>1;
		if (A[mid] >= s) hi = mid - 1, left = mid;
		else lo = mid + 1;
	}
	lo = 1, hi = N;
	while (lo <= hi){
		int mid = (lo+hi)>>1;
		if (A[mid] <= t) lo = mid + 1, right = mid;
		else hi = mid - 1;
	}
	if (left > right) *mn = *mx = -1;
	else{
		*mn = A[left];
		*mx = A[right];
	}
	if (subtask_num == 1) call_count++;
	else if (subtask_num == 2) call_count += right-left+2;
}

int main()
{    
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	FILE *in = stdin, *out = stdout;
	my_assert(2 == fscanf(in, "%d%d", &subtask_num, &N));
	my_assert(1 <= subtask_num && subtask_num <= 2);
	my_assert(2 <= N && N <= 100000);
	for (int i=1;i<=N;i++) my_assert(1 == fscanf(in, "%lld", A+i));
	for (int i=1;i<N;i++) my_assert(A[i] < A[i+1]);
	fprintf(out, "%lld\n", findGap(subtask_num, N));
	fprintf(out, "%lld\n", call_count);
}
#endif

using ll = long long;
ll findGap(int t, int n) {
    set<ll> Q;
    auto rec = [&](auto &&rec, ll l, ll r) -> void {
        if (l > r) {
            return;
        }
        
        MinMax(l, r, &l, &r);
        
        if (l == -1) {
            return;
        } else {
            Q.insert(l);
            Q.insert(r);
            l++;
            r--;
            rec(rec, l, (l + r) / 2);
            rec(rec, (l + r) / 2 + 1, r);
        }
    };
    rec(rec, 0, ((ll)1e9) * ((ll)1e9));
    vector<ll> F(Q.begin(), Q.end());
    ll res = 0;
    for (int i = 0; i + 1 < n; i++) {
        res = max(res, F[i + 1] - F[i]);
    }
    return res;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

1 2
29659227736649406 728704890713443211

output:

699045662976793805
3

result:

points 0 M = 3

Subtask #2:

score: 12.8863
Acceptable Answer

Test #33:

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

input:

2 2
78103569500113815 605712887753065418

output:

527609318252951603
5

result:

points 1.0 M = 5

Test #34:

score: 53.1367
Acceptable Answer
time: 0ms
memory: 6120kb

input:

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

output:

158717465145313148
53

result:

points 0.7590960460 M = 53

Test #35:

score: 53.8866
Acceptable Answer
time: 1ms
memory: 5776kb

input:

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

output:

141470620841118761
52

result:

points 0.76980881820 M = 52

Test #36:

score: 53.8866
Acceptable Answer
time: 1ms
memory: 6112kb

input:

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

output:

281070690232818333
52

result:

points 0.76980881820 M = 52

Test #37:

score: 53.1367
Acceptable Answer
time: 0ms
memory: 3876kb

input:

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

output:

2018243
53

result:

points 0.7590960460 M = 53

Test #38:

score: 37.3208
Acceptable Answer
time: 0ms
memory: 3816kb

input:

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

output:

54067555940387079
580

result:

points 0.5331548220 M = 580

Test #39:

score: 37.3208
Acceptable Answer
time: 0ms
memory: 4048kb

input:

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

output:

59713872839546348
580

result:

points 0.5331548220 M = 580

Test #40:

score: 37.1439
Acceptable Answer
time: 0ms
memory: 3820kb

input:

2 100
20951091854749146 39386665336762106 65348999538428106 66362035795586210 81709370165386396 93863216036002253 94954124765945570 98416678462344831 100179150589549359 101661786858873791 105784523081581573 133226904081376290 140305891886384108 142435215842805186 147141020482961557 16014850887196140...

output:

63628383529967709
584

result:

points 0.53062710850 M = 584

Test #41:

score: 37.1439
Acceptable Answer
time: 0ms
memory: 4092kb

input:

2 100
8683327277022804 11525898743460835 21889838648491707 22672985361995142 22871403829960514 26185108082514386 32278252100720302 33089530954981957 40328531272599111 50378942708165318 52742999006847442 58686369529165391 59657257882342356 75920087864374263 77612399236626250 79374212457599324 9623783...

output:

40066697874077492
584

result:

points 0.53062710850 M = 584

Test #42:

score: 37.9579
Acceptable Answer
time: 0ms
memory: 5816kb

input:

2 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
566

result:

points 0.54225606970 M = 566

Test #43:

score: 26.5985
Acceptable Answer
time: 1ms
memory: 6196kb

input:

2 1500
1618213394018307 1726930763754608 2124196573509900 3188921652963049 5833539893163331 6250580943582345 8009567796404888 8108094926328577 8945400972051512 9068415002879990 9271557812428261 9341188699880057 9859270332344853 10606266273849543 11273652445272988 12445096047739936 13345617466280107 ...

output:

4966493272906105
14400

result:

points 0.37997893920 M = 14400

Test #44:

score: 26.5889
Acceptable Answer
time: 0ms
memory: 5920kb

input:

2 1500
423747667147233 1561287032774385 2815102099958249 2952899121610206 4640725990792096 5567835982926405 5959730234172331 6248117786743912 6405494934002246 6629771121755127 6875079844550057 6982182413663121 7694307063121361 7873901115883013 8269828576806131 8941612085736550 8993641910826693 10809...

output:

4541692825618767
14408

result:

points 0.37984103760 M = 14408

Test #45:

score: 26.6009
Acceptable Answer
time: 0ms
memory: 6192kb

input:

2 1500
64452176748519 1374238003151922 1481992832337076 1607611500442259 2524275411594920 2819805885128544 2999188890512186 3582137882865248 3714829534718349 3760219840453438 4193234657878435 5073579666080273 5329403710938273 5333319328123345 5417167916136217 5563144406337463 5672112941300640 627477...

output:

4642293045041442
14398

result:

points 0.38001343570 M = 14398

Test #46:

score: 26.613
Acceptable Answer
time: 0ms
memory: 5924kb

input:

2 1500
324495733956306 332471995186936 1058899393043155 1314847657762888 1526581777794606 2625690753986526 2946426278678007 3064028147086651 3478433600054624 4490997176023002 4670521435154482 5418343765305672 5494527866902768 5746595830756539 6127626432201785 6434483331246781 7417569222871253 813523...

output:

6122034287537034
14388

result:

points 0.38018604470 M = 14388

Test #47:

score: 27.0973
Acceptable Answer
time: 1ms
memory: 5852kb

input:

2 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
13997

result:

points 0.38710491410 M = 13997

Test #48:

score: 21.2279
Acceptable Answer
time: 9ms
memory: 7112kb

input:

2 25000
112605853915943 125305907674152 144506263929928 145048005466654 186625763697557 250970014919178 272013066291825 277464146092542 315028577810248 324826653633832 331628639654030 366116577518536 393799455295566 457306447540263 537970740820978 545132699389716 602258814216849 630828934540371 6329...

output:

410686271327381
341046

result:

points 0.30325605840 M = 341046

Test #49:

score: 21.2242
Acceptable Answer
time: 14ms
memory: 5184kb

input:

2 25000
53697824651228 59941694110355 105281841854384 140773815786506 195080124596830 205602872513176 232550393702661 250839320965836 357336305944960 445772327889742 458411558573039 480097388109225 589547835152279 654519812791613 657909554075110 658074250564130 660528980346543 681471369638132 706174...

output:

430267194921600
341142

result:

points 0.30320223590 M = 341142

Test #50:

score: 21.2255
Acceptable Answer
time: 14ms
memory: 5436kb

input:

2 25000
236383646331590 309738640102496 415679754080064 451409199781921 458344303144135 473319547754108 481873731528972 560017045057239 703680773731679 714643104611577 746043561795946 771747078040695 776656199478820 789505769224804 797742246243146 837185561400326 890024880459743 918825337944933 9516...

output:

487268024112545
341109

result:

points 0.30322073440 M = 341109

Test #51:

score: 21.2238
Acceptable Answer
time: 10ms
memory: 5168kb

input:

2 25000
52783945537122 62819045853889 103029326755590 127343774652669 145637982794158 212055356045416 335256425611226 451536398811681 453303675422389 475376257071292 489441103616660 533619294493363 562495294237103 572516073983838 583118994056080 619557063671801 625182087503880 692493046036241 716280...

output:

599893247137814
341150

result:

points 0.30319775190 M = 341150

Test #52:

score: 21.4085
Acceptable Answer
time: 10ms
memory: 5440kb

input:

2 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
336500

result:

points 0.30583510940 M = 336500

Test #53:

score: 19.4835
Acceptable Answer
time: 53ms
memory: 10968kb

input:

2 100000
3977422187752 9172657585884 24850889798563 26187011217882 31651873376550 75673343339240 79205495884761 88387369684010 105989931083541 141113143182522 143101275900551 148426692305199 150824146224816 176873845082992 202163514907605 213337134915131 214840001575911 221606598395231 2293864027207...

output:

130710364094545
1564252

result:

points 0.27833610740 M = 1564252

Test #54:

score: 19.4834
Acceptable Answer
time: 57ms
memory: 9620kb

input:

2 100000
13262637344137 25327517069541 37585568091323 38365340074891 47727605278793 58706463955550 61784803233883 80374709463294 87412393644839 88101573585840 90609123343133 101420152174745 105940140827265 106131254494335 115396943403518 132897981932105 156021235615380 164076967932544 16943555464990...

output:

120119470217307
1564272

result:

points 0.2783338920 M = 1564272

Test #55:

score: 19.4847
Acceptable Answer
time: 56ms
memory: 9488kb

input:

2 100000
18832120122902 29507339632281 39898560623404 40778639373134 41910660835777 43088996832597 51347744889484 56014606055243 90815300081822 108951223881642 112329690251402 116131225732135 121551899536730 127626505168556 147850636284574 148528364776400 157535250520691 173227762441871 191532776595...

output:

131100462117639
1564103

result:

points 0.27835261440 M = 1564103

Test #56:

score: 19.4822
Acceptable Answer
time: 53ms
memory: 10924kb

input:

2 100000
6181561812375 6378266039481 17448377100925 23317298637346 24337449409681 26044481406381 32692256431578 37974050602069 56379269012502 62795819601065 71760296467148 78440221129293 78930025852339 80931924595168 83701405144700 86908947992706 88064472595619 103912708748713 107984687050829 109849...

output:

147711566772217
1564417

result:

points 0.2783178310 M = 1564417

Test #57:

score: 19.6909
Acceptable Answer
time: 43ms
memory: 9400kb

input:

2 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
1537893

result:

points 0.28129891690 M = 1537893

Test #58:

score: 19.4859
Acceptable Answer
time: 48ms
memory: 11028kb

input:

2 100000
535929232534 21492335528903 25556131309717 28889553256515 38280084435606 57205171519054 63131861600620 78001720289062 80340150523608 83049214992797 84430304388156 102774222420109 112544520828566 117204763271484 147765688281362 153490305322347 153616558263633 155397223860355 165839368261394 ...

output:

162924923640912
1563947

result:

points 0.27836989980 M = 1563947

Test #59:

score: 19.4854
Acceptable Answer
time: 56ms
memory: 11004kb

input:

2 100000
9057012105366 20678972320055 21561791756347 39835717708647 54928587965288 55153553053797 68595004021437 81018678910692 97365149371768 103887761862034 115587676356349 130903585150729 133639436033175 141700198339591 159584386350410 172139818896137 173902145536266 183123687931554 1855949817876...

output:

117217672541541
1564009

result:

points 0.27836302960 M = 1564009

Test #60:

score: 19.4826
Acceptable Answer
time: 51ms
memory: 11000kb

input:

2 100000
7697039304820 22564329077790 23102661676835 30879851103816 41796239317938 52087405646978 59030372710103 68926959255910 71706259524723 83233183164047 83415881967147 100648405518975 120970003699941 139103178498777 143930857549424 145210161583126 165760166063479 168852347637729 181589636505000...

output:

109432203596644
1564368

result:

points 0.27832325820 M = 1564368

Test #61:

score: 19.4848
Acceptable Answer
time: 53ms
memory: 10992kb

input:

2 100000
39366590558911 39585546629301 66569120610179 81894310350738 87175880111275 89442953960573 96350792731838 102015133304594 104040476597055 137132585901068 147415403324850 157386830894481 171251327732554 177384689100207 178816731020000 184834516398044 190021715201563 205391984563936 2070227259...

output:

123267759045505
1564092

result:

points 0.27835383320 M = 1564092

Test #62:

score: 19.6273
Acceptable Answer
time: 38ms
memory: 10892kb

input:

2 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
1545904

result:

points 0.28038929650 M = 1545904

Test #63:

score: 12.8863
Acceptable Answer
time: 1ms
memory: 5828kb

input:

2 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
3657

result:

points 0.1840900990 M = 3657

Test #64:

score: 16.4484
Acceptable Answer
time: 1ms
memory: 6076kb

input:

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

output:

500000000000000000
2431

result:

points 0.23497771330 M = 2431