QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#305815 | #7560. Computer Network | NemanjaSo2005 | WA | 1ms | 5680kb | C++14 | 847b | 2024-01-16 01:15:29 | 2024-01-16 01:15:30 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e6+5;
ll A[maxn],B[maxn];
ll N;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>N;
for(int i=1;i<=N;i++)
cin>>A[i];
for(int i=1;i<=N;i++)
cin>>B[i];
ll res=1e18;
for(int k=2;k<=2;k++){
ll l=-1e18,r=1e18;
for(int i=1;i<=N;i++){
l=max(l,B[i]*(1<<k)-A[i]);
r=min(r,B[i]*(1<<k)+(1<<k)-1-A[i]);
}
if(r<0 or r<l)
continue;
if(l==0){
res=min(res,(ll)k);
continue;
}
while(l<=r){
res=min(res,l/(1ll<<k)+__builtin_popcount(l&((1ll<<k)-1))+k);
if(l==0)break;
l+=l&-l;
}
}
if(res<1e18)
cout<<res<<"\n";
else
cout<<"-1\n";
return 0;
}
/*
5
1 2 3 4 5
6 6 6 6 7
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5588kb
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: 5676kb
input:
3 2 3 4 1 2 3
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5680kb
input:
2 65536 65537 1 2
output:
-1
result:
wrong answer 1st numbers differ - expected: '32', found: '-1'