QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#205109 | #7560. Computer Network | ucup-team1448# | WA | 1ms | 5840kb | C++14 | 1.3kb | 2023-10-07 14:53:44 | 2023-10-07 14:53:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template <typename T> void rd(T &x) {
x = 0;
int f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - 48;
c = getchar();
}
x *= f;
}
template <typename T, typename... T2> void rd(T &x, T2 &...y) {
rd(x), rd(y...);
}
using ll = long long;
const int Nmax = 1e6 + 5, Vmax = 30;
const ll inf = 1e18;
int n;
ll a[Nmax], b[Nmax], ans = inf;
int main() {
rd(n);
for (int i = 1; i <= n; ++i)
rd(a[i]);
for (int i = 1; i <= n; ++i)
rd(b[i]);
for (int i = 0; i < Vmax; ++i) {
ll l = 0, r = inf;
for (int j = 1; j <= n; ++j) {
l = max(l, (b[j] << i) - a[j]);
r = min(r, ((b[j] + 1) << i) - a[j]);
// printf("<%d %d>\n", (b[j] << i) - a[j], ((b[j] + 1) << i) -
// a[j]);
}
// printf("%lld %lld\n", l, r);
ll mn = inf;
if (l) {
for (; l < r; l += l & -l)
mn = min(mn,
(l >> i) + __builtin_popcount(l & ((1ll << i) - 1)));
} else {
mn = 0;
}
ans = min(ans, mn + i);
}
printf("%lld", ans == inf ? -1 : ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5816kb
input:
5 1 2 3 4 5 6 6 6 6 7
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5840kb
input:
3 2 3 4 1 2 3
output:
0
result:
wrong answer 1st numbers differ - expected: '-1', found: '0'