QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214534#7560. Computer Networktriple__a#WA 1ms5756kbC++17682b2023-10-14 20:51:072023-10-14 20:51:07

Judging History

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

  • [2023-10-14 20:51:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5756kb
  • [2023-10-14 20:51:07]
  • 提交

answer

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

const int N=1000007;
const int INF=LLONG_MAX/4;
int n;
int a[N],b[N];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i) cin>>b[i];
	int ans=-1;
	for (int _=0;_<30;++_){
		int L=0,R=INF;
		for (int i=1;i<=n;++i) L=max(L,b[i]*(1ll<<_)-a[i]);
		for (int i=1;i<=n;++i) R=min(R,(b[i]+1)*(1ll<<_)-a[i]-1);
		cerr<<_<<" "<<L<<" "<<R<<endl;
		if (L>R) continue;
		ans=L/(1ll<<_)+_, L%=(1ll<<_), R-=(ans-_)*(1ll<<_);
		while (L<R) L/=2, R/=2;
		ans+=__builtin_popcountll(L); 
		break;
	}
	cout<<ans<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 2 3 4 5
6 6 6 6 7

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

3
2 3 4
1 2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

2
65536 65537
1 2

output:

32

result:

ok 1 number(s): "32"

Test #4:

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

input:

1
0
28

output:

28

result:

ok 1 number(s): "28"

Test #5:

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

input:

1
249912
43

output:

25

result:

wrong answer 1st numbers differ - expected: '26', found: '25'