QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#217809#1086. Bank Security UnificationzhouhuanyiWA 1ms5680kbC++14562b2023-10-17 14:30:062023-10-17 14:30:06

Judging History

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

  • [2023-10-17 14:30:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5680kb
  • [2023-10-17 14:30:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 1000000
using namespace std;
long long read()
{
	char c=0;
	long long sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
int n,top;
long long dque[N+1],a[N+1],ans;
int main()
{
	n=read();
	for (int i=1;i<=n;++i)
	{
		a[i]=read();
		while (top>=2&&(dque[top-1]&dque[top])+(dque[top]&a[i])<=(dque[top-1]&a[i])) top--;
		dque[++top]=a[i];
	}
	for (int i=1;i<=top-1;++i) ans+=(dque[i]&dque[i+1]);
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5620kb

input:

5
1 2 3 1 3

output:

5

result:

ok answer is '5'

Test #2:

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

input:

4
1 2 4 0

output:

0

result:

ok answer is '0'

Test #3:

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

input:

2
1000000000000 1000000000000

output:

1000000000000

result:

ok answer is '1000000000000'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5680kb

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:

3625709767790

result:

wrong answer expected '4105724254392', found '3625709767790'