QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841192 | #8857. Low Power | isWFnoya | AC ✓ | 183ms | 23412kb | C++23 | 1.1kb | 2025-01-03 15:06:17 | 2025-01-03 15:06:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=2e6+10;
ll n,m,k;
ll ans;
ll a[N];
bool tf[N];
vector<PII> tg;
bool check(ll mid){
vector<PII> v;
int i=1;
while(i<m&&v.size()<n){
if(a[i+1]-a[i]<=mid){
v.push_back({i,i+1});
i++;
}
i++;
}
if(v.size()<n) return false;
reverse(v.begin(),v.end());
ll cnt=0;
for(int i=0;i<n;i++){
if(v[i].second>tg[i].first) return false;
if(v[i].first>tg[i].second) return false;
}
return true;
}
int main()
{
cin>>n>>k;
// int nn=2*n*;
m=2*n*k;
for(int i=m;i>0;){
i=i-k+1;
PII res;
res.first=i;
i--;
i=i-k+1;
res.second=i;
i--;
tg.push_back(res);
}
for(int i=1;i<=m;i++) scanf("%lld",&a[i]);
sort(a+1,a+1+m);
ll l=0,r=1e9;
while(l<r){
ll mid=l+r>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<l<<endl;
}
//51423
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6008kb
input:
2 3 1 2 3 4 5 6 7 8 9 10 11 12
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5932kb
input:
2 2 3 1 3 3 3 3 3 3
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5728kb
input:
2 3 1 2 3 4 5 6 7 8 9 10 11 12
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5784kb
input:
2 2 3 1 3 3 3 3 3 3
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 5608kb
input:
1 1 1 1
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5948kb
input:
1 1 2 999999999
output:
999999997
result:
ok single line: '999999997'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5944kb
input:
1 1 1000000000 1
output:
999999999
result:
ok single line: '999999999'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
1 1 1000000000 1000000000
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5732kb
input:
1 2 4 8 2 1
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 5784kb
input:
1 2 4 9 6 1
output:
3
result:
ok single line: '3'
Test #11:
score: 0
Accepted
time: 0ms
memory: 5740kb
input:
1 2 4 9 4 1
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 1ms
memory: 5728kb
input:
1 2 9 8 1 4
output:
3
result:
ok single line: '3'
Test #13:
score: 0
Accepted
time: 1ms
memory: 5724kb
input:
2 1 4 8 2 1
output:
4
result:
ok single line: '4'
Test #14:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
2 1 4 9 6 1
output:
3
result:
ok single line: '3'
Test #15:
score: 0
Accepted
time: 1ms
memory: 5716kb
input:
2 1 4 9 4 1
output:
5
result:
ok single line: '5'
Test #16:
score: 0
Accepted
time: 1ms
memory: 5932kb
input:
2 1 9 8 1 4
output:
3
result:
ok single line: '3'
Test #17:
score: 0
Accepted
time: 1ms
memory: 5680kb
input:
2 2 9 8 8 8 7 6 5 5
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 0ms
memory: 5688kb
input:
2 2 9 9 9 8 7 6 5 5
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 0ms
memory: 5708kb
input:
4 1 9 7 7 7 6 5 4 4
output:
2
result:
ok single line: '2'
Test #20:
score: 0
Accepted
time: 0ms
memory: 5748kb
input:
4 1 9 9 9 8 7 6 5 5
output:
1
result:
ok single line: '1'
Test #21:
score: 0
Accepted
time: 1ms
memory: 5976kb
input:
4 2 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 1ms
memory: 5784kb
input:
4 2 8 8 8 8 8 8 8 8 8 8 1 8 8 8 8 8
output:
7
result:
ok single line: '7'
Test #23:
score: 0
Accepted
time: 1ms
memory: 5708kb
input:
4 2 1 2 4 6 8 9 11 13 15 16 18 20 22 23 23 23
output:
1
result:
ok single line: '1'
Test #24:
score: 0
Accepted
time: 1ms
memory: 5656kb
input:
4 2 1 2 4 6 8 9 11 13 15 16 18 20 22 24 25 25
output:
2
result:
ok single line: '2'
Test #25:
score: 0
Accepted
time: 1ms
memory: 5712kb
input:
4 1 999999999 1 999999998 4 999999997 8 999999996 13
output:
5
result:
ok single line: '5'
Test #26:
score: 0
Accepted
time: 1ms
memory: 5736kb
input:
4 5 130 132 133 137 193 195 213 218 228 337 351 368 373 383 405 455 495 514 565 609 619 732 733 761 805 806 808 811 841 852 886 921 925 925 972 977 1013 1078 1081 1115
output:
4
result:
ok single line: '4'
Test #27:
score: 0
Accepted
time: 1ms
memory: 5936kb
input:
1 1 9 5
output:
4
result:
ok single line: '4'
Test #28:
score: 0
Accepted
time: 0ms
memory: 5748kb
input:
3 7 262 862 914 204 996 325 780 813 220 535 28 48 560 357 620 823 52 245 577 807 612 516 227 539 256 264 895 403 496 20 687 98 790 980 793 158 842 535 94 400 661 831
output:
8
result:
ok single line: '8'
Test #29:
score: 0
Accepted
time: 1ms
memory: 5968kb
input:
8 9 606572 678033 38629 697360 156173 76283 592922 643557 40336 326606 229481 597158 37984 362302 288977 532121 441984 961701 769379 645420 492784 116377 733219 173221 608436 131481 827399 202098 731237 646734 362102 182978 709313 615859 913515 189880 574542 578831 788460 712417 458643 927807 217729...
output:
6067
result:
ok single line: '6067'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
3 1 854785954 268128164 869890063 651183983 820638480 789424527
output:
383055819
result:
ok single line: '383055819'
Test #31:
score: 0
Accepted
time: 0ms
memory: 5964kb
input:
717 6 2 2 5 6 8 9 3 8 8 1 2 6 6 7 5 5 8 7 4 7 7 8 6 8 1 1 3 1 9 3 6 6 4 2 7 8 5 3 8 6 8 3 7 3 3 7 6 9 7 9 8 9 1 5 3 5 6 4 9 4 7 6 6 1 3 3 4 1 4 9 3 1 3 7 4 3 8 1 4 3 8 8 7 3 1 2 5 5 5 9 7 2 6 6 3 5 2 5 2 7 9 2 7 9 2 3 9 3 7 7 2 2 4 5 9 3 1 1 5 7 5 3 9 4 4 1 4 6 4 3 5 6 2 1 4 2 3 1 6 7 8 1 6 9 6 7 6 ...
output:
0
result:
ok single line: '0'
Test #32:
score: 0
Accepted
time: 2ms
memory: 5668kb
input:
660 7 110 190 857 587 224 681 423 776 603 903 30 707 676 423 55 443 493 995 10 279 840 590 974 302 602 427 544 540 808 607 426 275 700 227 633 134 672 283 683 102 326 75 856 417 402 108 441 731 744 129 425 348 415 679 273 17 946 316 248 541 273 826 891 899 136 593 563 883 953 820 355 31 620 136 929 ...
output:
0
result:
ok single line: '0'
Test #33:
score: 0
Accepted
time: 2ms
memory: 5996kb
input:
855 6 325224 840968 763942 92841 889873 440887 29165 894592 885173 528536 586775 420576 570367 45205 764593 494934 530702 130480 17040 870001 609760 3165 543704 596464 300633 565554 238571 49770 66762 171152 549514 368570 440010 64596 627448 953050 68936 874455 826024 578677 887287 897783 325941 458...
output:
103
result:
ok single line: '103'
Test #34:
score: 0
Accepted
time: 1ms
memory: 6012kb
input:
359 6 996668359 465674598 190737937 969365298 688757535 537774760 540233644 727291488 287507273 540567350 185071789 913066953 730623130 821832675 350829413 215706491 225309418 193848370 282599030 623537925 928199219 684742068 9776580 369532078 892914795 107366543 334912655 794070089 145222660 700066...
output:
42689
result:
ok single line: '42689'
Test #35:
score: 0
Accepted
time: 47ms
memory: 13620kb
input:
75109 5 4 4 3 1 9 6 7 4 8 6 5 1 1 4 4 4 1 5 6 9 6 5 9 6 8 2 1 6 6 4 5 2 1 2 4 8 3 8 1 8 3 9 3 8 8 2 5 4 6 9 1 6 2 7 7 2 8 9 2 3 6 8 9 5 2 9 2 7 7 2 8 9 1 8 3 3 7 1 6 5 5 6 3 7 5 7 4 1 9 5 1 8 5 3 3 4 3 7 9 3 4 8 6 1 8 2 6 3 7 1 2 4 8 9 4 2 6 7 3 2 4 5 5 9 4 4 1 4 3 7 2 9 1 8 2 2 5 6 7 7 8 8 5 8 7 1 ...
output:
0
result:
ok single line: '0'
Test #36:
score: 0
Accepted
time: 70ms
memory: 15312kb
input:
246215 1 844 137 389 167 258 38 296 668 909 61 541 805 823 781 672 383 557 795 495 14 474 505 263 690 190 692 832 880 143 394 206 828 416 637 140 516 647 724 805 260 383 262 527 977 844 745 131 21 339 130 939 871 638 86 603 962 36 892 954 591 633 905 953 93 953 556 312 990 66 70 602 721 367 160 117 ...
output:
1
result:
ok single line: '1'
Test #37:
score: 0
Accepted
time: 76ms
memory: 12732kb
input:
193938 1 280592 428150 32951 850571 727958 347048 685305 697482 80888 372433 959784 509501 417890 652738 340481 110213 781543 71841 967433 642999 30324 410109 112057 458931 226108 377586 70628 2843 677388 155266 410153 427628 972518 268278 44209 951221 202520 595932 198650 42366 274833 48253 186779 ...
output:
31
result:
ok single line: '31'
Test #38:
score: 0
Accepted
time: 124ms
memory: 21160kb
input:
275064 1 808960512 815707652 427306637 509492314 316533364 256976333 249887107 211385132 947775176 604037424 707299014 143318230 402424620 133067523 177730786 198806699 826784866 146448287 883180416 966345655 251031524 223747442 439149274 740862186 564921034 118964000 47016655 241342574 914077320 41...
output:
25464
result:
ok single line: '25464'
Test #39:
score: 0
Accepted
time: 1ms
memory: 5600kb
input:
5 711 6 5 1 9 3 5 9 2 3 8 9 3 6 7 7 1 1 1 7 6 8 2 1 5 9 1 5 1 5 9 3 9 3 3 8 7 9 2 7 8 3 1 9 8 6 9 2 2 8 4 2 3 9 7 5 4 7 9 6 3 6 3 7 3 3 8 8 4 5 3 3 6 7 2 5 1 3 8 4 2 5 1 6 7 4 4 5 5 4 6 9 4 9 4 9 3 9 6 9 5 8 4 6 6 5 4 4 4 6 9 5 8 6 3 3 9 4 2 9 8 3 5 7 1 3 1 2 7 7 2 1 3 4 3 4 1 1 4 1 7 4 9 3 8 3 2 5 ...
output:
0
result:
ok single line: '0'
Test #40:
score: 0
Accepted
time: 0ms
memory: 7976kb
input:
5 237 103 350 860 26 466 88 919 58 281 223 584 692 955 930 363 568 236 877 20 314 296 22 303 327 358 366 659 735 101 481 355 355 448 88 187 37 996 92 429 452 936 525 736 83 14 857 347 709 86 922 438 894 773 561 195 364 890 915 223 486 287 967 487 328 713 726 781 133 438 797 512 305 845 470 319 193 5...
output:
0
result:
ok single line: '0'
Test #41:
score: 0
Accepted
time: 2ms
memory: 5968kb
input:
9 949 311888 350216 560670 365341 297619 538229 447771 910623 338536 500929 610750 498394 599734 988319 940258 246409 201774 62504 541547 30635 907873 700845 451754 44153 430901 919553 760586 206344 842378 369396 379006 730950 298471 142533 917641 335852 301049 378917 381946 712297 493474 931653 999...
output:
8
result:
ok single line: '8'
Test #42:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
3 846 705048379 283042607 456015803 151131671 180670002 656097790 373881495 711341624 415084230 519486167 415104705 528376826 7293245 133041623 64470364 264973033 348706824 351195455 759160128 353128740 849888803 829220657 936090751 231783301 346835494 717847180 765750293 672117717 883076478 9956400...
output:
19781
result:
ok single line: '19781'
Test #43:
score: 0
Accepted
time: 7ms
memory: 7988kb
input:
56 976 7 3 3 2 8 9 7 4 5 1 9 7 6 2 8 8 8 6 5 5 4 8 6 7 8 2 1 8 8 3 7 5 4 1 7 1 7 2 1 8 2 4 5 5 5 1 7 5 8 3 1 8 3 4 7 6 4 3 7 3 7 1 2 9 9 3 4 6 5 7 6 1 8 4 6 7 1 5 1 9 2 3 9 1 2 7 7 2 1 7 6 7 1 7 7 5 5 4 1 6 5 8 8 4 5 7 1 3 8 2 6 5 8 9 4 3 1 1 8 1 5 9 4 3 3 5 6 2 3 2 6 5 7 4 7 3 3 2 8 6 1 1 5 3 8 6 4...
output:
0
result:
ok single line: '0'
Test #44:
score: 0
Accepted
time: 26ms
memory: 7768kb
input:
372 389 902 863 776 712 51 168 128 99 296 856 796 739 196 432 90 93 697 38 313 990 797 841 241 573 804 375 761 158 876 775 72 770 360 44 543 498 966 984 283 395 622 200 922 513 45 587 656 433 547 61 313 270 811 356 139 800 235 233 700 705 262 183 920 439 894 905 54 130 214 670 215 349 867 40 749 775...
output:
0
result:
ok single line: '0'
Test #45:
score: 0
Accepted
time: 40ms
memory: 7720kb
input:
633 290 532125 821200 381253 673757 472978 885021 515084 64339 382897 53501 256133 155661 532214 561696 672247 582376 682683 647193 47612 608908 200479 630182 392059 891950 77693 638782 957934 809682 210267 430500 592170 350026 610203 580085 39441 700220 273332 971420 622151 229758 490952 842832 380...
output:
3
result:
ok single line: '3'
Test #46:
score: 0
Accepted
time: 25ms
memory: 7796kb
input:
559 225 348136550 857562919 374229360 418887551 126922654 973227967 816776853 221415408 220638342 861028903 419221946 573679530 873278858 363075424 487799542 1334394 447756876 900050891 546298572 267384134 780696052 586727973 481828945 972619042 394105276 418620628 99928431 481494550 525862166 49405...
output:
905
result:
ok single line: '905'
Test #47:
score: 0
Accepted
time: 34ms
memory: 9736kb
input:
2 135576 5 9 3 9 7 5 5 4 2 3 3 9 8 3 1 4 2 4 7 6 3 8 1 8 7 1 8 7 7 4 3 2 5 8 3 4 4 4 1 6 7 9 2 9 2 8 7 8 6 7 7 1 2 6 5 7 9 4 9 7 1 3 7 8 6 5 7 9 9 3 5 1 8 7 6 7 4 4 9 6 7 2 8 9 7 1 6 2 5 4 1 9 4 4 6 2 3 4 7 4 6 8 3 7 9 2 3 2 5 6 5 8 6 7 4 7 8 4 4 2 2 3 9 6 6 5 8 2 7 3 1 7 9 5 4 5 1 5 6 2 7 8 4 9 2 2...
output:
0
result:
ok single line: '0'
Test #48:
score: 0
Accepted
time: 80ms
memory: 13848kb
input:
7 65485 328 976 14 942 255 40 914 696 314 909 334 998 378 338 905 391 753 347 423 218 87 843 22 424 840 748 938 631 671 503 335 729 553 828 490 910 888 804 890 859 248 394 479 171 315 420 904 569 283 510 529 54 330 888 41 368 739 910 984 471 95 238 390 939 151 206 207 31 210 241 222 735 936 971 851 ...
output:
0
result:
ok single line: '0'
Test #49:
score: 0
Accepted
time: 5ms
memory: 5644kb
input:
5 4070 957112 99853 252449 160906 456801 387603 383923 484691 256170 120546 928314 352942 527579 157316 868097 768407 896140 140975 773392 384405 513236 776593 212661 421449 856825 356920 908496 444254 525309 716850 583527 525091 931017 748715 505189 163077 668265 575096 840218 61935 637768 951415 9...
output:
15
result:
ok single line: '15'
Test #50:
score: 0
Accepted
time: 7ms
memory: 7832kb
input:
2 19076 153176801 499289536 666319782 166038207 723519030 334652042 585925258 333392840 482494723 731043331 221422320 513403172 181216038 983205187 65723549 56384112 789884143 846563996 398279929 732330710 573889390 59840812 626141676 884876757 552114671 590684203 994117264 570757564 95992613 705550...
output:
6381
result:
ok single line: '6381'
Test #51:
score: 0
Accepted
time: 78ms
memory: 13980kb
input:
207 2403 928 86 68 842 972 781 727 510 784 388 583 735 581 707 329 741 763 800 980 819 957 385 226 254 247 259 65 485 491 447 279 246 528 116 230 34 999 278 60 745 543 561 999 814 227 437 340 974 815 949 386 595 440 263 949 571 377 13 922 975 756 428 627 337 544 502 478 65 959 540 580 503 308 541 91...
output:
0
result:
ok single line: '0'
Test #52:
score: 0
Accepted
time: 177ms
memory: 23412kb
input:
500000 1 983555377 465304929 299701424 739500476 255490810 861557198 913571495 196621513 996040163 318365107 778213878 811825124 213066136 530735235 18663684 38713402 556334314 351508938 617163740 822042171 42673240 237969207 573295061 805338616 608976036 511938005 219305524 534581660 249004303 2574...
output:
13479
result:
ok single line: '13479'
Test #53:
score: 0
Accepted
time: 183ms
memory: 19404kb
input:
250000 2 648935923 666200434 646930976 19876013 790654636 584927572 442068788 897888607 519618798 494989478 72671463 550993296 248952685 853418364 848058502 52795450 760338660 664025114 411349577 950169895 533176653 265349182 591353651 860356282 701217211 679758289 417290681 538558202 100017623 3719...
output:
514
result:
ok single line: '514'
Test #54:
score: 0
Accepted
time: 132ms
memory: 13920kb
input:
1 500000 17023186 121796822 56514055 41806583 575457160 825261385 485057669 879352209 825235889 279847380 43735645 233465022 862329024 703439067 223333325 1929063 658007862 37067639 218381398 343981117 176693175 378160482 993331994 984916377 481652094 473254109 154827158 991402932 326908515 44458445...
output:
2682
result:
ok single line: '2682'
Test #55:
score: 0
Accepted
time: 128ms
memory: 13852kb
input:
2 250000 824568877 296410459 516297083 677182883 192790360 101919040 830427843 142096145 203808818 742087599 905077676 92955003 317527268 907398360 225790517 227894793 900164644 215608229 76970517 83694372 24085975 158077046 310530554 984015514 766167104 116687616 932286530 82635761 83850870 5505588...
output:
861
result:
ok single line: '861'
Test #56:
score: 0
Accepted
time: 122ms
memory: 14184kb
input:
1000 500 636402796 125044118 425094298 539425023 970549498 283173472 389692371 143626175 428293153 191510403 108225903 993315354 507223379 403249034 766416106 568800880 122765856 324049906 113556663 722789930 240507726 931255453 315824003 120241309 315566550 837258693 264839347 747023124 997475454 9...
output:
631
result:
ok single line: '631'
Test #57:
score: 0
Accepted
time: 82ms
memory: 16292kb
input:
100000 5 1 1 1003 2005 3007 4009 5011 6013 7015 8017 9019 9020 10022 11024 12026 13028 14030 15032 16034 17036 18038 18039 19041 20043 21045 22047 23049 24051 25053 26055 27057 27058 28060 29062 30064 31066 32068 33070 34072 35074 36076 36077 37079 38081 39083 40085 41087 42089 43091 44093 45095 450...
output:
1000
result:
ok single line: '1000'