QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#857194#1086. Bank Security Unificationpiggy123AC ✓552ms19288kbC++172.7kb2025-01-15 12:05:162025-01-15 12:05:16

Judging History

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

  • [2025-01-15 12:05:16]
  • 评测
  • 测评结果:AC
  • 用时:552ms
  • 内存:19288kb
  • [2025-01-15 12:05:16]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll a[1000005],dp[1000005],lst[66];

int main(){
	ll n;
	cin >> n;
	for (ll i=1;i<=n;i++){
		cin >> a[i];
	}
	ll ans=0,pre=0;
	for (ll i=1;i<=n;i++){dp[i]=pre;
		for (ll j=0;j<62;j++){
			if (lst[j])
			dp[i]=max(dp[i],dp[lst[j]]+(a[i]&a[lst[j]]));	
		}pre=max(pre,dp[i]);
		for (ll j=0;j<62;j++){
			if (a[i]>>j&1)lst[j]=i;
		}
		ans=max(ans,dp[i]);
	}
	cout<< ans;
	return 0;
}

/*
                                                                
 ■■■■■     ■■      ■■■     ■■■   ■    ■     ■     ■■■■    ■■■■  
 ■   ■■    ■■     ■  ■■   ■  ■■  ■    ■    ■■     ■  ■■  ■■  ■  
 ■    ■    ■■    ■    ■  ■    ■   ■  ■    ■■■    ■■  ■■  ■   ■■ 
 ■    ■    ■■    ■    ■  ■    ■   ■  ■     ■■    ■   ■■      ■■ 
 ■    ■    ■■    ■       ■         ■■      ■■        ■■      ■  
 ■   ■■    ■■    ■  ■■■  ■  ■■■    ■■      ■■       ■■     ■■■  
 ■■■■■     ■■    ■    ■  ■    ■    ■■      ■■      ■■        ■■ 
 ■         ■■    ■    ■  ■    ■    ■■      ■■     ■■          ■ 
 ■         ■■    ■    ■  ■    ■    ■■      ■■     ■      ■   ■■ 
 ■         ■■    ■■  ■■  ■■  ■■    ■■      ■■    ■       ■■  ■■ 
 ■         ■■      ■■■■    ■■■■    ■■      ■■    ■■■■■■   ■■■■  
*/

详细

Test #1:

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

input:

5
1 2 3 1 3

output:

5

result:

ok answer is '5'

Test #2:

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

input:

4
1 2 4 0

output:

0

result:

ok answer is '0'

Test #3:

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

input:

2
1000000000000 1000000000000

output:

1000000000000

result:

ok answer is '1000000000000'

Test #4:

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

input:

100
42357619991 34637578715 14383875856 65298594968 204835436802 17842451301 27263566591 56672847581 9938910048 37783918480 178688553850 31652616803 34569713543 278151742734 458183081930 36307485267 52046737444 29733829337 156411959819 70476873663 322768771475 306850928242 68922415915 108092954267 1...

output:

4105724254392

result:

ok answer is '4105724254392'

Test #5:

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

input:

200
32491481529 22326116709 38413035282 6379551923 17186666096 710945826 99671547638 21583864468 43358433566 110817310097 58936170734 12118139703 99298292577 7807334015 283126465825 29798702686 966557737 78175604253 84922374374 66149759365 4499380469 17953982120 22738453560 35389367375 71164988711 1...

output:

4385401630265

result:

ok answer is '4385401630265'

Test #6:

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

input:

300
0 0 0 7227130 0 44665356632 741540074 3252 1053109 0 0 3343976697 299282315 7 57190829 0 4379965174 17883634737 17400873810 3693 134 144164936555 320312270 0 0 423566 549 0 1979 0 0 0 2462345997 1021629061 483112 0 172597 11 0 0 0 0 3189174969 64832 14166776345 69159 0 0 56330326146 0 1206275174...

output:

2110095119925

result:

ok answer is '2110095119925'

Test #7:

score: 0
Accepted
time: 343ms
memory: 19156kb

input:

1000000
380994485120 380994485121 380994485122 380994485123 380994485124 380994485125 380994485126 380994485127 380994485128 380994485129 380994485130 380994485131 380994485132 380994485133 380994485134 380994485135 380994485136 380994485137 380994485138 380994485139 380994485140 380994485141 380994...

output:

56209236563089050

result:

ok answer is '56209236563089050'

Test #8:

score: 0
Accepted
time: 325ms
memory: 19284kb

input:

999947
694442488933 694442488934 694442488935 694442488936 694442488937 694442488938 694442488939 694442488940 694442488941 694442488942 694442488943 694442488944 694442488945 694442488946 694442488947 694442488948 694442488949 694442488950 694442488951 694442488952 694442488953 694442488954 6944424...

output:

53476040131480818

result:

ok answer is '53476040131480818'

Test #9:

score: 0
Accepted
time: 321ms
memory: 19284kb

input:

999990
622530347171 622530347172 622530347173 622530347174 622530347175 622530347176 622530347177 622530347178 622530347179 622530347180 622530347181 622530347182 622530347183 622530347184 622530347185 622530347186 622530347187 622530347188 622530347189 622530347190 622530347191 622530347192 6225303...

output:

59655875519862620

result:

ok answer is '59655875519862620'

Test #10:

score: 0
Accepted
time: 319ms
memory: 19280kb

input:

999910
116060584011 116060584012 116060584013 116060584014 116060584015 116060584016 116060584017 116060584018 116060584019 116060584020 116060584021 116060584022 116060584023 116060584024 116060584025 116060584026 116060584027 116060584028 116060584029 116060584030 116060584031 116060584032 1160605...

output:

37600735249746864

result:

ok answer is '37600735249746864'

Test #11:

score: 0
Accepted
time: 545ms
memory: 19288kb

input:

999980
973456184999 994679955061 993282175653 986051760436 954528887794 971573107627 996867749843 974175945534 965645059409 948673925746 962475247646 943221827884 987108127588 950169443307 918838723437 973511911195 996442323027 937608082925 997085429522 986532516116 969352518578 945143680447 9986449...

output:

902808284804665118

result:

ok answer is '902808284804665118'

Test #12:

score: 0
Accepted
time: 549ms
memory: 19284kb

input:

999910
981804924069 993068644407 972553472049 997366211901 951558543560 971846343773 813196870765 998061906229 982655806513 930622991527 984343959371 970826388690 995204841006 953323887709 979105600608 923189652758 967575164499 948270918453 976227432556 867116017989 972847233021 981119978185 9396479...

output:

905128344512512150

result:

ok answer is '905128344512512150'

Test #13:

score: 0
Accepted
time: 514ms
memory: 19284kb

input:

999936
25622203424 23487942008 41846404244 4374430937 21910375052 3108899134 20185511495 4455557875 42806661842 56370037380 43364758665 52822782975 34256333894 103004353803 80820299610 10675150544 28850405021 6079651716 3573334559 46743312294 63680217570 30618578145 36920171463 28470905057 904112253...

output:

20164611117398530

result:

ok answer is '20164611117398530'

Test #14:

score: 0
Accepted
time: 512ms
memory: 19280kb

input:

999987
11296929440 3829248220 16110883502 108978342265 2439137426 46560640772 346674808 30554463920 32615816900 54993560414 70317538277 4369646784 70001149917 12270150542 63590841758 32691739830 33277030825 74020183023 49709960612 88388172284 53864086705 8919782253 77173128886 47741816096 3158211906...

output:

17850294803699038

result:

ok answer is '17850294803699038'

Test #15:

score: 0
Accepted
time: 552ms
memory: 19284kb

input:

999950
965451514895 928786263913 995753155457 920660095725 975630178104 936271639198 936597205250 966542858200 975353440835 984130693812 838646587156 928864562822 835106340229 915163790869 965604614865 962450220083 657845241722 987487117331 998737597695 974274620652 920272247043 966117123618 9707261...

output:

840108611551824264

result:

ok answer is '840108611551824264'

Test #16:

score: 0
Accepted
time: 399ms
memory: 19156kb

input:

999994
11487015629 96368587486 51702167159 50716618412 51327709589 31911160521 39369096207 25538663648 130373113724 40961852769 59282165353 10662167580 39124876381 52968321160 45194719247 33547539009 96556439298 48019555217 30123457327 8663212992 11813153788 10999633300 7846446836 40028182342 514380...

output:

135299515549954901

result:

ok answer is '135299515549954901'

Test #17:

score: 0
Accepted
time: 398ms
memory: 19284kb

input:

999996
1073741824 1024 34359738368 137438953472 33554432 8192 1048576 137438953472 1048576 8192 8388608 4096 137438953472 33554432 1048576 274877906944 68719476736 128 8 4 1048576 4294967296 16 1048576 32 67108864 32768 4 32 536870912 1048576 256 17179869184 128 32 16 512 4294967296 549755813888 102...

output:

321034390265803051

result:

ok answer is '321034390265803051'

Test #18:

score: 0
Accepted
time: 441ms
memory: 19280kb

input:

999994
524288 1048576 8388608 8192 137438953472 17179869184 1 2097152 128 2097152 2097152 1024 1048576 2 1024 4 67108864 1073741824 8388608 2097152 536870912 8388608 17179869184 8589934592 68719476736 1048576 4 131072 2147483648 1 137438953472 8589934592 2147483648 34359738368 34359738368 4096 64 13...

output:

235653309942276920

result:

ok answer is '235653309942276920'

Test #19:

score: 0
Accepted
time: 387ms
memory: 19284kb

input:

999991
223551271527 133942442916 86939371421 183143354396 56504348482 64818767951 44264419136 47294191059 117630842464 15542116719 41990448816 78380314341 44386890113 10202071215 64282683242 61622847203 73396150638 154024547476 104165424254 15746486026 13676119224 60672174051 728271404 114542798143 ...

output:

176027867038140096

result:

ok answer is '176027867038140096'

Test #20:

score: 0
Accepted
time: 390ms
memory: 19284kb

input:

999991
16777216 268435456 1073741824 256 4294967296 32768 8388608 8589934592 17179869184 4194304 2097152 1 16384 65536 4096 16384 262144 2097152 34359738368 2147483648 274877906944 1073741824 536870912 34359738368 16777216 524288 256 549755813888 17179869184 34359738368 1 262144 8388608 256 8192 256...

output:

120929680834199012

result:

ok answer is '120929680834199012'

Test #21:

score: 0
Accepted
time: 383ms
memory: 19280kb

input:

1000000
548682072063 515396075519 549755813871 549755682815 515396075519 549755813886 549487378431 274877906943 549739036671 549755813631 549755289599 549755797503 549755811839 515396075519 549755809791 547608330239 541165879295 549755289599 481036337151 549755813885 515396075519 541165879295 549755...

output:

299351539718099798

result:

ok answer is '299351539718099798'

Test #22:

score: 0
Accepted
time: 385ms
memory: 19284kb

input:

1000000
210616201455 105560716790 16447258103 27858186232 208691922336 1125220424 107300867031 29957810501 833957499 308759811 78529621444 122964862323 25132739097 5169180543 106208873201 142490854205 37957832056 36736173813 66961455925 171269557350 18320614333 99679971371 22616443128 23865085226 65...

output:

179490432768376297

result:

ok answer is '179490432768376297'

Test #23:

score: 0
Accepted
time: 447ms
memory: 19260kb

input:

1000000
4388287287 132887244250 53788663362 77970947924 35016181210 18935678174 28902440471 87509896913 58547250753 55871165145 180873100851 65377459162 72815604760 221287226095 32796697184 2709792252 42931188752 157146523595 121034968503 114452324637 14396274986 54548544395 37206383835 175911614482...

output:

236598394308419545

result:

ok answer is '236598394308419545'

Test #24:

score: 0
Accepted
time: 430ms
memory: 19284kb

input:

1000000
549755813871 547608330239 549751619583 549755748351 549487378431 549755682815 549755797503 515396075519 548682072063 549755551743 549747425279 549755813879 549755781119 481036337151 549218942975 549621596159 541165879295 549755813631 549739036671 547608330239 549755781119 549755748351 549739...

output:

472055104408081976

result:

ok answer is '472055104408081976'

Test #25:

score: 0
Accepted
time: 368ms
memory: 19156kb

input:

1000000
820483397150 983141633308 988904085441 975938935104 996789252023 997425580433 999699483311 987577329334 839731757349 762734764182 923129428133 949594906349 990868379739 992169622388 941371255921 925508427272 917584502805 926363401395 948090893308 914545348502 851931396466 979026577192 989758...

output:

255115955188771164

result:

ok answer is '255115955188771164'

Test #26:

score: 0
Accepted
time: 438ms
memory: 19284kb

input:

1000000
547608330239 549755809791 412316860415 532575944703 549755812863 549755813886 549755813823 545460846591 549753716735 549755813883 549755813879 549755809791 549751619583 549755748351 549722259455 549755813883 548682072063 548682072063 549755781119 549755748351 549755781119 549621596159 549218...

output:

520855018228327407

result:

ok answer is '520855018228327407'

Test #27:

score: 0
Accepted
time: 308ms
memory: 19244kb

input:

1000000
8192 16 32768 32 536870912 2097152 1048576 16777216 134217728 134217728 2 1073741824 32768 536870912 8388608 33554432 8192 524288 16384 2 549755813888 8192 256 4 33554432 512 68719476736 16 8 33554432 268435456 17179869184 524288 2048 32768 68719476736 4294967296 32768 16777216 32 4294967296...

output:

15359335635721243

result:

ok answer is '15359335635721243'

Test #28:

score: 0
Accepted
time: 415ms
memory: 19156kb

input:

999993
128 268435456 524288 1048576 2048 34359738368 1024 32 256 65536 1 65536 2097152 2147483648 524288 8192 268435456 4096 16777216 1 8589934592 16384 64 8 2147483648 128 512 33554432 524288 32 512 536870912 549755813888 268435456 65536 2 4294967296 262144 16777216 128 2 262144 34359738368 4096 27...

output:

431782162576124941

result:

ok answer is '431782162576124941'

Test #29:

score: 0
Accepted
time: 316ms
memory: 18300kb

input:

787546
515396075519 547608330239 274877906943 549218942975 549621596159 549755809791 549755813879 549487378431 549755805695 549747425279 549755748351 549755813879 549755813855 515396075519 549755551743 274877906943 549755813631 549755682815 532575944703 549755813886 545460846591 549755811839 5494873...

output:

136324939598900550

result:

ok answer is '136324939598900550'