QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214521 | #7560. Computer Network | triple__a# | RE | 1ms | 5744kb | C++17 | 654b | 2023-10-14 20:41:31 | 2023-10-14 20:41:31 |
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;
assert(L==R);
ans=L/(1ll<<_)+_, L%=(1ll<<_);
ans+=__builtin_popcountll(L);
break;
}
cout<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5672kb
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: 5744kb
input:
2 65536 65537 1 2
output:
32
result:
ok 1 number(s): "32"
Test #4:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
1 0 28
output:
28
result:
ok 1 number(s): "28"
Test #5:
score: -100
Runtime Error
input:
1 249912 43