QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209683 | #5150. Alternating Algorithm | 275307894a | TL | 76ms | 8204kb | C++14 | 1.1kb | 2023-10-10 16:33:06 | 2023-10-10 16:33:08 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e6+5,M=N*4,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int n,A[N],B[N],vis[N];
void Solve(){
int i,j;scanf("%d",&n);
for(i=0;i<=n;i++) scanf("%d",&A[i]),B[i]=i;
sort(B,B+n+1,[](int x,int y){return A[x]^A[y]?A[x]<A[y]:x<y;});
int ans=0;
for(i=0;i<n;i++){
vis[B[i]]=1;
int tot=-INF,Ct=0;
for(j=0;j<=n;j++) if(vis[j]){
Ct++;if(Ct-1==j) continue;
tot=max(tot+1,j+(j%2==0)-Ct+1);
}
ans=max(ans,tot);
}
printf("%d\n",ans);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 8076kb
input:
3 8 13 4 10
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 8148kb
input:
5 13 12 14 10 14 12
output:
3
result:
ok single line: '3'
Test #3:
score: 0
Accepted
time: 0ms
memory: 8200kb
input:
2 2 2 1
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 8152kb
input:
1 300172042 474444146
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 1ms
memory: 8148kb
input:
1 636357447 557539481
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 8016kb
input:
2 139715426 368724097 417561009
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 1ms
memory: 8144kb
input:
2 77784868 542697475 509604021
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 1ms
memory: 8076kb
input:
2 698395658 71848686 699775597
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 1ms
memory: 8140kb
input:
2 487635147 571273621 442673389
output:
3
result:
ok single line: '3'
Test #10:
score: 0
Accepted
time: 1ms
memory: 8024kb
input:
2 502022170 254766224 258867503
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 1ms
memory: 8140kb
input:
2 783651505 271735448 154090385
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 0ms
memory: 8164kb
input:
3 423187900 701340783 708457090 788989478
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 0ms
memory: 8076kb
input:
3 172068101 507957913 237246316 805323765
output:
2
result:
ok single line: '2'
Test #14:
score: 0
Accepted
time: 0ms
memory: 8144kb
input:
3 309846480 218704879 536482379 754210806
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 0ms
memory: 8096kb
input:
3 150235215 485036833 52089968 645641645
output:
3
result:
ok single line: '3'
Test #16:
score: 0
Accepted
time: 0ms
memory: 8096kb
input:
3 735389981 669677621 733676260 858050940
output:
2
result:
ok single line: '2'
Test #17:
score: 0
Accepted
time: 0ms
memory: 8164kb
input:
3 635103474 551413670 85269704 730878535
output:
3
result:
ok single line: '3'
Test #18:
score: 0
Accepted
time: 0ms
memory: 8040kb
input:
3 287528440 314452762 846234936 452787633
output:
1
result:
ok single line: '1'
Test #19:
score: 0
Accepted
time: 0ms
memory: 8168kb
input:
3 276069955 969481471 992185356 536479156
output:
2
result:
ok single line: '2'
Test #20:
score: 0
Accepted
time: 1ms
memory: 8148kb
input:
3 225096493 88165689 415816372 360778803
output:
1
result:
ok single line: '1'
Test #21:
score: 0
Accepted
time: 1ms
memory: 8124kb
input:
3 651934487 760368054 975264908 206290402
output:
3
result:
ok single line: '3'
Test #22:
score: 0
Accepted
time: 1ms
memory: 8124kb
input:
3 668819975 16012633 798541220 258404088
output:
2
result:
ok single line: '2'
Test #23:
score: 0
Accepted
time: 1ms
memory: 8148kb
input:
3 303955151 276719749 324951113 63908344
output:
3
result:
ok single line: '3'
Test #24:
score: 0
Accepted
time: 1ms
memory: 8156kb
input:
3 419862649 709195111 424612582 548104611
output:
3
result:
ok single line: '3'
Test #25:
score: 0
Accepted
time: 1ms
memory: 8124kb
input:
3 46436854 762650424 543885894 63420906
output:
3
result:
ok single line: '3'
Test #26:
score: 0
Accepted
time: 1ms
memory: 8016kb
input:
3 663885616 817966829 428282021 750799481
output:
3
result:
ok single line: '3'
Test #27:
score: 0
Accepted
time: 0ms
memory: 8148kb
input:
3 453815838 784866392 626401113 33629018
output:
3
result:
ok single line: '3'
Test #28:
score: 0
Accepted
time: 1ms
memory: 8100kb
input:
3 612031283 905623341 296446821 317142883
output:
4
result:
ok single line: '4'
Test #29:
score: 0
Accepted
time: 1ms
memory: 8148kb
input:
3 690093550 720639503 493410469 329723725
output:
4
result:
ok single line: '4'
Test #30:
score: 0
Accepted
time: 1ms
memory: 8196kb
input:
3 640270086 11003869 302770972 380428351
output:
3
result:
ok single line: '3'
Test #31:
score: 0
Accepted
time: 0ms
memory: 8104kb
input:
3 813904638 53916473 202342438 178710524
output:
3
result:
ok single line: '3'
Test #32:
score: 0
Accepted
time: 1ms
memory: 8140kb
input:
3 858480562 107901831 70069694 624943715
output:
3
result:
ok single line: '3'
Test #33:
score: 0
Accepted
time: 1ms
memory: 8144kb
input:
3 972814426 208602080 487914166 199127689
output:
3
result:
ok single line: '3'
Test #34:
score: 0
Accepted
time: 0ms
memory: 8152kb
input:
3 527326624 369552716 30514207 190802344
output:
4
result:
ok single line: '4'
Test #35:
score: 0
Accepted
time: 0ms
memory: 8200kb
input:
3 885560774 510753464 330831417 122397162
output:
4
result:
ok single line: '4'
Test #36:
score: 0
Accepted
time: 0ms
memory: 8168kb
input:
1 0 0
output:
0
result:
ok single line: '0'
Test #37:
score: 0
Accepted
time: 1ms
memory: 8160kb
input:
1 1 0
output:
1
result:
ok single line: '1'
Test #38:
score: 0
Accepted
time: 1ms
memory: 8152kb
input:
1 0 1
output:
0
result:
ok single line: '0'
Test #39:
score: 0
Accepted
time: 0ms
memory: 8144kb
input:
1 1000000000 0
output:
1
result:
ok single line: '1'
Test #40:
score: 0
Accepted
time: 1ms
memory: 8156kb
input:
5 870923667 831419329 551216223 626357192 564992248 642950852
output:
6
result:
ok single line: '6'
Test #41:
score: 0
Accepted
time: 1ms
memory: 8144kb
input:
5 436264160 745635157 20618089 707614372 862629566 987729003
output:
3
result:
ok single line: '3'
Test #42:
score: 0
Accepted
time: 1ms
memory: 8200kb
input:
5 112182501 364650582 622093010 819594012 467586768 328068426
output:
4
result:
ok single line: '4'
Test #43:
score: 0
Accepted
time: 0ms
memory: 8104kb
input:
6 440802446 672072796 870079224 289645602 358794408 131990964 936527350
output:
5
result:
ok single line: '5'
Test #44:
score: 0
Accepted
time: 0ms
memory: 8020kb
input:
6 624312076 675425489 51650975 686013685 309942426 127494361 289215201
output:
6
result:
ok single line: '6'
Test #45:
score: 0
Accepted
time: 0ms
memory: 8100kb
input:
7 406067722 563548194 1821761 121198244 605039142 435891339 752521249 231257069
output:
5
result:
ok single line: '5'
Test #46:
score: 0
Accepted
time: 0ms
memory: 8152kb
input:
8 903342821 163731172 682809514 389316549 725357000 720997713 96340788 793801888 869342849
output:
8
result:
ok single line: '8'
Test #47:
score: 0
Accepted
time: 0ms
memory: 8140kb
input:
9 363831817 704177455 355821226 562295495 935390976 836136856 341398270 776676829 529678510 52558572
output:
9
result:
ok single line: '9'
Test #48:
score: 0
Accepted
time: 1ms
memory: 8160kb
input:
10 246145909 225986170 30947233 986106325 383647644 975836729 294340164 499272928 869685867 565345319 614315474
output:
8
result:
ok single line: '8'
Test #49:
score: 0
Accepted
time: 2ms
memory: 8204kb
input:
1000 231332114 230630192 351420646 113555257 459531950 528889159 722843423 767109901 199940885 361818296 601674519 520787125 373984526 131582326 735571682 913614536 427646918 492788875 885493950 729293776 86866411 301642177 596103707 286017188 404978221 99164884 557969075 824451476 786229179 6568911...
output:
988
result:
ok single line: '988'
Test #50:
score: 0
Accepted
time: 2ms
memory: 8152kb
input:
1000 201237580 262233610 521393924 204754621 944681640 932601690 489080953 412917668 883036649 563431807 688539831 23217206 191387217 865135843 444220860 919291668 854282608 531215553 795310206 541494885 189990980 261726893 19326520 324075439 507080845 418920882 763004786 24752713 97017512 806297757...
output:
963
result:
ok single line: '963'
Test #51:
score: 0
Accepted
time: 2ms
memory: 8152kb
input:
1000 245854962 961065710 265834001 409991314 502843324 264413634 168737457 377744352 877338730 410425691 420584311 39857486 514628666 202702540 609556882 140763320 179454201 95682353 944425082 773206968 48828602 444907192 847750785 211128579 644847799 653342226 111489102 840616371 769383066 21778409...
output:
968
result:
ok single line: '968'
Test #52:
score: 0
Accepted
time: 0ms
memory: 8148kb
input:
1000 56860094 538493381 554439030 206424842 790663806 579157036 387486471 84800487 791214857 386235 609988396 916272543 265220272 464978622 313488958 827753905 117409349 269536105 680933797 411190692 241417332 189233067 97516924 153711068 699639043 594790214 255340740 512431744 925598028 564907259 7...
output:
946
result:
ok single line: '946'
Test #53:
score: 0
Accepted
time: 2ms
memory: 8152kb
input:
1000 499167410 308258055 571510863 76211631 531244106 48049595 345102098 998984144 637392389 514345792 831894385 644167459 112603566 698584608 827071664 12522880 477664194 61691301 417702956 195033072 398097815 634730885 705739071 200342256 623489046 246611507 364884964 167061289 491390084 602418473...
output:
994
result:
ok single line: '994'
Test #54:
score: 0
Accepted
time: 76ms
memory: 8200kb
input:
10000 345264059 315478859 833122581 330403342 575068916 227323513 683477770 863935533 978755270 32100490 287168446 617003274 382166828 34585886 663715160 78805796 528053673 690209780 385941801 129293384 841635538 593208658 661022964 704453339 503774844 244624738 559109248 211457091 410419325 8856822...
output:
9928
result:
ok single line: '9928'
Test #55:
score: 0
Accepted
time: 75ms
memory: 8176kb
input:
10000 815828170 945127833 424330804 776118575 397026265 715443961 925353374 901904669 340418102 432682697 674494824 675281569 447057850 338062821 318551961 460405714 100220176 76947210 945061782 797189448 303277121 697496533 536096786 562191201 480931188 602534528 157276350 159537956 717726491 85685...
output:
9922
result:
ok single line: '9922'
Test #56:
score: 0
Accepted
time: 75ms
memory: 8172kb
input:
10000 289278063 433331753 347595732 527307083 399705652 514579488 156785023 155968246 756401984 8043111 92819946 409628119 62979151 34406175 987104395 958719612 677025103 373428742 163849749 634439517 295369897 48024082 674158532 521451335 662854517 570785380 225752183 135465963 892303405 983083565 ...
output:
9877
result:
ok single line: '9877'
Test #57:
score: 0
Accepted
time: 76ms
memory: 8116kb
input:
10000 179324925 473779524 228723339 719220248 914030472 115680201 245782379 220143110 479262455 883201027 189476723 121459923 345976778 509305587 977140563 11817128 329404935 382625086 987602657 286028783 578716942 237013199 664277486 203856501 524916212 129608611 52854596 499627532 873016497 904200...
output:
9965
result:
ok single line: '9965'
Test #58:
score: 0
Accepted
time: 75ms
memory: 8180kb
input:
10000 416740428 521620677 921094562 483566618 839804083 759426723 409345291 588409358 877124316 899377301 185200929 820913118 303097088 247710858 52195585 366437919 249984237 576252113 332208990 204967179 173885150 556984226 134159314 877891989 363004507 872104788 120687087 885164478 986024409 88661...
output:
9892
result:
ok single line: '9892'
Test #59:
score: -100
Time Limit Exceeded
input:
400000 215058725 944123539 406091240 395706777 160799139 16550738 606292593 769270022 662115918 894553476 787977401 655777269 239587736 686438029 121819098 512402422 407228764 656179090 243900087 698815378 76264274 786169236 713920134 434963769 540632492 54900575 405182025 360448964 784543975 360831...