QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214532 | #7560. Computer Network | triple__a# | WA | 1ms | 5736kb | C++17 | 674b | 2023-10-14 20:48:10 | 2023-10-14 20:48:11 |
Judging History
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%=(1ll<<_);
while (L<R) L/=2, R/=2;
ans+=__builtin_popcountll(L);
break;
}
cout<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5604kb
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: 0ms
memory: 5600kb
input:
3 2 3 4 1 2 3
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5684kb
input:
2 65536 65537 1 2
output:
32
result:
ok 1 number(s): "32"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5736kb
input:
1 0 28
output:
28
result:
ok 1 number(s): "28"
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 5684kb
input:
1 249912 43
output:
32
result:
wrong answer 1st numbers differ - expected: '26', found: '32'