QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#257094#7560. Computer Networkviniciuslettieri#WA 0ms3488kbC++20984b2023-11-19 00:05:532023-11-19 00:05:53

Judging History

你现在查看的是最新测评结果

  • [2023-11-19 00:05:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3488kb
  • [2023-11-19 00:05:53]
  • 提交

answer

#include<bits/stdc++.h>

int main() {
    using i64 = int64_t;
    using namespace std;
    cin.tie(nullptr)->sync_with_stdio(false);
    int N; cin >> N;

    vector<i64> A(N); for (i64& a : A) cin >> a;
    vector<i64> B(N); for (i64& b : B) cin >> b;

    const i64 INF = 1e18;
    i64 res = INF;
    for (int pw = 0; pw < 32; ++pw) {
        i64 lo = 0, hi = INF;
        for (int i = 0; i < N; ++i) {
            i64 l = B[i] << pw;
            i64 h = (B[i] + 1LL) << pw;
            lo = max(lo, l - A[i]);
            hi = min(hi, h - A[i]);
        }

        if (lo < hi) {
            while (lo < hi) {
                i64 l = lo;
                i64 s = 0;
                for (int i = 0; i < pw; ++i) {
                    s += (l % 2);
                    l /= 2;
                }
                res = min(res, s + l + pw);
                lo *= 2;
            }       
        }
    }
    cout << (res == INF ? -1 : res) << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 3488kb

input:

3
2 3 4
1 2 3

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3420kb

input:

2
65536 65537
1 2

output:

32

result:

ok 1 number(s): "32"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3328kb

input:

1
0
28

output:

28

result:

ok 1 number(s): "28"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3488kb

input:

1
249912
43

output:

32

result:

wrong answer 1st numbers differ - expected: '26', found: '32'