QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207020 | #7560. Computer Network | ucup-team180# | WA | 0ms | 3528kb | C++17 | 1.2kb | 2023-10-08 03:16:57 | 2023-10-08 03:16:58 |
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<__int128_t> a(n);
for (int i = 0; i < n; i++){
long long x;
cin >> x;
a[i] = x;
}
vector<__int128_t> b(n);
for (int i = 0; i < n; i++){
long long x;
cin >> x;
b[i] = x;
}
__int128_t INF2 = 1;
for (int i = 0; i < 36; i++){
INF2 *= 10;
}
long long ans = INF;
for (int i = 0; i < 60; i++){
__int128_t L = -INF2, R = INF2;
for (int j = 0; j < n; j++){
__int128_t mn = (b[j] << i) - a[j];
__int128_t mx = ((b[j] + 1) << i) - 1 - a[j];
mn = max(mn, (__int128_t) 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: 0ms
memory: 3496kb
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: 3528kb
input:
3 2 3 4 1 2 3
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
2 65536 65537 1 2
output:
32
result:
ok 1 number(s): "32"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
1 0 28
output:
28
result:
ok 1 number(s): "28"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3468kb
input:
1 249912 43
output:
32
result:
wrong answer 1st numbers differ - expected: '26', found: '32'