QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207019 | #7560. Computer Network | ucup-team180# | WA | 1ms | 3464kb | C++17 | 1.0kb | 2023-10-08 03:11:52 | 2023-10-08 03:11:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++){
cin >> a[i];
}
vector<long long> b(n);
for (int i = 0; i < n; i++){
cin >> b[i];
}
long long ans = INF;
for (int i = 0; i < 32; i++){
long long L = -INF, R = INF;
for (int j = 0; j < n; j++){
long long mn = (b[j] << i) - a[j];
long long mx = ((b[j] + 1) << i) - 1 - a[j];
mn = max(mn, (long long) 0);
if (mn > mx){
L = INF;
R = -INF;
} else {
L = max(L, mn);
R = min(R, mx);
}
}
if (L <= R){
long long cnt = i;
for (int j = 0; j < i; j++){
if (L % 2 == 1){
cnt++;
}
L /= 2;
}
cnt += L;
ans = min(ans, cnt);
}
}
if (ans == INF){
cout << -1 << endl;
} else {
cout << ans << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3404kb
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: 3428kb
input:
3 2 3 4 1 2 3
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
2 65536 65537 1 2
output:
32
result:
ok 1 number(s): "32"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
1 0 28
output:
28
result:
ok 1 number(s): "28"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3424kb
input:
1 249912 43
output:
32
result:
wrong answer 1st numbers differ - expected: '26', found: '32'