QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214542#7560. Computer Networktriple__a#WA 1ms5668kbC++17723b2023-10-14 20:56:062023-10-14 20:56:07

Judging History

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

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

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<<_);
		// cerr<<L<<" "<<R<<" "<<ans<<endl;
		while (L+1<R) L/=2, R/=2;
		ans+=__builtin_popcountll(R); 
		break;
	}
	cout<<ans<<"\n";
}

详细

Test #1:

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

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: 5640kb

input:

3
2 3 4
1 2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

2
65536 65537
1 2

output:

32

result:

ok 1 number(s): "32"

Test #4:

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

input:

1
0
28

output:

28

result:

ok 1 number(s): "28"

Test #5:

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

input:

1
249912
43

output:

26

result:

ok 1 number(s): "26"

Test #6:

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

input:

2
52522336 155670
52532336 165670

output:

10000

result:

ok 1 number(s): "10000"

Test #7:

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

input:

2
141839218 538313890
17731054 67290388

output:

1155

result:

ok 1 number(s): "1155"

Test #8:

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

input:

2
678834913 571995689
84855772 71500869

output:

1411

result:

ok 1 number(s): "1411"

Test #9:

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

input:

10
66 0 65 10 40 1 44 29 13 15
84 18 83 28 58 19 62 47 31 33

output:

18

result:

ok 1 number(s): "18"

Test #10:

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

input:

10
0 74752 70656 67584 29696 44032 80896 22528 1024 52224
2 75 71 68 31 45 81 24 3 53

output:

13

result:

wrong answer 1st numbers differ - expected: '12', found: '13'