QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#204762 | #7560. Computer Network | ucup-team866# | WA | 1ms | 5660kb | C++14 | 746b | 2023-10-07 13:52:18 | 2023-10-07 13:52:19 |
Judging History
answer
#include <bits/stdc++.h>
#include <climits>
using namespace std;
typedef long long ll;
const int N = 1e6 + 6;
int n, a[N], b[N]; ll ans = LLONG_MAX;
int main() {
cin >> n;
for (int i=1; i<=n; i++)
scanf ("%d", &a[i]);
for (int i=1; i<=n; i++)
scanf ("%d", &b[i]);
for (int d=0; d<=31; d++) {
ll L = 0, R = LLONG_MAX;
for (int i=1; i<=n; i++)
L = max(L, (1ll * b[i] << d) - a[i]),
R = min(R, (1ll * b[i] + 1 << d) - a[i] - 1);
if (L > R) continue;
int t = 62;
for (; ~t; t--) if (L >> t & 1 ^ R >> t & 1) break; t ++;
if (t && (L & (1ll << t) - 1)) L = L >> t << t | 1;
ans = min(ans, (L >> d) + __builtin_popcountll(L & (1ll << d) - 1) + d);
} cout << (ans == LLONG_MAX ? - 1 : ans) << endl;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5600kb
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: 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: 5656kb
input:
2 65536 65537 1 2
output:
32
result:
ok 1 number(s): "32"
Test #4:
score: 0
Accepted
time: 0ms
memory: 5660kb
input:
1 0 28
output:
28
result:
ok 1 number(s): "28"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5644kb
input:
1 249912 43
output:
26
result:
ok 1 number(s): "26"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5580kb
input:
2 52522336 155670 52532336 165670
output:
10000
result:
ok 1 number(s): "10000"
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 5592kb
input:
2 141839218 538313890 17731054 67290388
output:
1028
result:
wrong answer 1st numbers differ - expected: '1155', found: '1028'