QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#485356#7678. The GameyaoyWA 24ms3796kbC++202.7kb2024-07-20 16:50:542024-07-20 16:50:54

Judging History

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

  • [2024-07-20 16:50:54]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3796kb
  • [2024-07-20 16:50:54]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> a(n), b(m);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
    }

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    bool ok = true;
    int dif = 0;
    for (int i = n - 1, j = m - 1; j >= 0; j--, i--) {
        ok &= (a[i] <= b[j]);
        dif += b[j] - a[i];
    }

    if (!ok || dif > n - m) {
        std::cout << -1 << "\n";
        return;
    }

    int r = n - m - dif;
    for (int i = 0; i < r; i++) {
        ok &= (a[i] + 1 <= b[0]);
    }
    if (!ok) {
        std::cout << -1 << "\n";
        return;
    }

    std::vector<int> ans;

    auto output = [&]() {
        std::cout << ans.size() << "\n";
        for (int i = 0; i < ans.size(); i++) {
            std::cout << ans[i] << " \n"[i == ans.size() - 1];
        }
    };

    std::multiset<int> Sb(b.begin(), b.end());
    auto check = [&]() -> bool {
        bool OK = true;
        std::multiset<int> Sa(a.begin(), a.end());
        for (auto &x : ans) {
            OK &= Sa.contains(x);
            Sa.extract(x);
            Sa.insert(x + 1);
            Sa.erase(Sa.begin());
        }
        OK &= (Sa == Sb);
        return OK;
    };

    std::multiset<int> S(a.begin(), a.begin() + n - m);
    for (int i = 0; i < r; i++) {
        int x = *S.begin();
        S.erase(S.begin());
        S.insert(x + 1);
        S.erase(S.begin());
        ans.emplace_back(x);
    }
    for (int j = 0, i = n - m; j < m; j++, i++) {
        for (int v = a[i]; v < b[j]; v++) {
            ans.emplace_back(v);
        }
    }

    if (check()) {
        output();
        return;
    }

    ans.clear();
    S = std::multiset<int> (a.begin(), a.begin() + n - m);
    for (int i = 0; i < r; i++) {
        while (!S.empty() && *S.rbegin() == b[0]) {
            S.extract(*S.rbegin());
        }
        if (S.empty()) {
            break;
        }
        int x = *S.rbegin();
        S.extract(*S.rbegin());
        S.insert(x + 1);
        S.erase(S.begin());
        ans.emplace_back(x);
    }
    for (int j = 0, i = n - m; j < m; j++, i++) {
        for (int v = a[i]; v < b[j]; v++) {
            ans.emplace_back(v);
        }
    }

    if (check()) {
        output();
        return;
    }


    std::cout << -1 << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}
 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3468kb

input:

6
5 3
1 2 2 3 3
2 3 4
4 2
1 2 2 4
2 4
5 2
2 3 3 4 4
5 5
6 1
1 1 1 1 1 1
4
4 2
1 1 1 2
2 2
4 1
1 1 1 1
2

output:

2
1 3
-1
3
2 4 4
5
1 1 1 2 3
2
1 1
-1

result:

ok ok (6 test cases)

Test #2:

score: 0
Accepted
time: 3ms
memory: 3552kb

input:

7056
4 3
1 1 1 1
1 1 1
4 3
1 1 1 1
1 1 2
4 3
1 1 1 1
1 1 3
4 3
1 1 1 1
1 1 4
4 3
1 1 1 1
1 1 5
4 3
1 1 1 1
1 1 6
4 3
1 1 1 1
1 2 2
4 3
1 1 1 1
1 2 3
4 3
1 1 1 1
1 2 4
4 3
1 1 1 1
1 2 5
4 3
1 1 1 1
1 2 6
4 3
1 1 1 1
1 3 3
4 3
1 1 1 1
1 3 4
4 3
1 1 1 1
1 3 5
4 3
1 1 1 1
1 3 6
4 3
1 1 1 1
1 4 4
4 3
1 1...

output:

-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
2
-1
-1
-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok ok (7056 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3540kb

input:

5880
4 2
1 1 1 1
1 1
4 2
1 1 1 1
1 2
4 2
1 1 1 1
1 3
4 2
1 1 1 1
1 4
4 2
1 1 1 1
1 5
4 2
1 1 1 1
1 6
4 2
1 1 1 1
1 7
4 2
1 1 1 1
2 2
4 2
1 1 1 1
2 3
4 2
1 1 1 1
2 4
4 2
1 1 1 1
2 5
4 2
1 1 1 1
2 6
4 2
1 1 1 1
2 7
4 2
1 1 1 1
3 3
4 2
1 1 1 1
3 4
4 2
1 1 1 1
3 5
4 2
1 1 1 1
3 6
4 2
1 1 1 1
3 7
4 2
1 1...

output:

-1
-1
2
1 2
-1
-1
-1
-1
2
1 1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
2 3
-1
-1
-1
2
1 1
2
1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
3 4
-1
-1
-1
2
1 1
2
1 3
-1
-1
-1
2
1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
4 5
...

result:

ok ok (5880 test cases)

Test #4:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

2640
4 1
1 1 1 1
1
4 1
1 1 1 1
2
4 1
1 1 1 1
3
4 1
1 1 1 1
4
4 1
1 1 1 1
5
4 1
1 1 1 1
6
4 1
1 1 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
-1
-1
-1
-1
-1
-1
-1
2
2 3
-1
-1
-1
2
1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
1 1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok ok (14112 test cases)

Test #6:

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

input:

5292
5 2
1 1 1 1 1
1 1
5 2
1 1 1 1 1
1 2
5 2
1 1 1 1 1
1 3
5 2
1 1 1 1 1
1 4
5 2
1 1 1 1 1
1 5
5 2
1 1 1 1 1
1 6
5 2
1 1 1 1 1
2 2
5 2
1 1 1 1 1
2 3
5 2
1 1 1 1 1
2 4
5 2
1 1 1 1 1
2 5
5 2
1 1 1 1 1
2 6
5 2
1 1 1 1 1
3 3
5 2
1 1 1 1 1
3 4
5 2
1 1 1 1 1
3 5
5 2
1 1 1 1 1
3 6
5 2
1 1 1 1 1
4 4
5 2
1 1...

output:

-1
-1
-1
3
1 2 3
-1
-1
3
1 1 1
3
1 1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
2 3 4
-1
-1
3
1 1 2
3
1 2 3
-1
-1
3
1 2 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
3 4 5
-1
-1
3
1 1 3
3
1 3 4
-1
3
1 1 2
3
1 2 3
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
1 1 4
3
1 4 5
-1
3
1 1...

result:

ok ok (5292 test cases)

Test #7:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

3234
5 1
1 1 1 1 1
1
5 1
1 1 1 1 1
2
5 1
1 1 1 1 1
3
5 1
1 1 1 1 1
4
5 1
1 1 1 1 1
5
5 1
1 1 1 1 1
6
5 1
1 1 1 1 1
7
5 1
1 1 1 1 2
1
5 1
1 1 1 1 2
2
5 1
1 1 1 1 2
3
5 1
1 1 1 1 2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1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok ok (8820 test cases)

Test #9:

score: 0
Accepted
time: 13ms
memory: 3612kb

input:

26460
6 5
1 1 1 1 1 1
1 1 1 1 1
6 5
1 1 1 1 1 1
1 1 1 1 2
6 5
1 1 1 1 1 1
1 1 1 1 3
6 5
1 1 1 1 1 1
1 1 1 1 4
6 5
1 1 1 1 1 1
1 1 1 1 5
6 5
1 1 1 1 1 1
1 1 1 2 2
6 5
1 1 1 1 1 1
1 1 1 2 3
6 5
1 1 1 1 1 1
1 1 1 2 4
6 5
1 1 1 1 1 1
1 1 1 2 5
6 5
1 1 1 1 1 1
1 1 1 3 3
6 5
1 1 1 1 1 1
1 1 1 3 4
6 5
1 1 ...

output:

-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok ok (26460 test cases)

Test #10:

score: 0
Accepted
time: 24ms
memory: 3744kb

input:

50000
6 4
1 1 1 1 1 1
1 1 1 1
6 4
1 1 1 1 1 1
1 1 1 2
6 4
1 1 1 1 1 1
1 1 1 3
6 4
1 1 1 1 1 1
1 1 1 4
6 4
1 1 1 1 1 1
1 1 1 5
6 4
1 1 1 1 1 1
1 1 1 6
6 4
1 1 1 1 1 1
1 1 2 2
6 4
1 1 1 1 1 1
1 1 2 3
6 4
1 1 1 1 1 1
1 1 2 4
6 4
1 1 1 1 1 1
1 1 2 5
6 4
1 1 1 1 1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1 1 2 3 4
5
1 2 3 4 5
-1
-1
-1
-1
5
1 1 1 2 2
5
1 1 1 2 3
5
1 1 2 3 4
5
1 2 3 4 5
5
2 3 4 5 6
-1
-1
-1
-1
5
1 1 1 2 3
5
1 1 1 3 4
5
1 1 3 4 5
5
1 3 4 5 6
5
3 4 5 6 7
-1
-1
-1
5
1 1 1 2 3
5
1 1 1 2 4
5
1 1 1 4 5
5
1 1 4 5 6
5
1 4 5 6 7
-1
-1
-1
-1
5
1 1 1 2 3
5
1 1 1 2...

result:

ok ok (13728 test cases)

Test #14:

score: 0
Accepted
time: 6ms
memory: 3480kb

input:

10080
7 6
1 1 1 1 1 1 1
1 1 1 1 1 1
7 6
1 1 1 1 1 1 1
1 1 1 1 1 2
7 6
1 1 1 1 1 1 1
1 1 1 1 1 3
7 6
1 1 1 1 1 1 1
1 1 1 1 1 4
7 6
1 1 1 1 1 1 1
1 1 1 1 2 2
7 6
1 1 1 1 1 1 1
1 1 1 1 2 3
7 6
1 1 1 1 1 1 1
1 1 1 1 2 4
7 6
1 1 1 1 1 1 1
1 1 1 1 3 3
7 6
1 1 1 1 1 1 1
1 1 1 1 3 4
7 6
1 1 1 1 1 1 1
1 1 1 ...

output:

-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
2
-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok ok (10080 test cases)

Test #15:

score: 0
Accepted
time: 6ms
memory: 3796kb

input:

23100
7 4
1 1 1 1 1 1 1
1 1 1 1
7 4
1 1 1 1 1 1 1
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1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok ok (41580 test cases)

Test #17:

score: 0
Accepted
time: 7ms
memory: 3748kb

input:

11550
7 3
1 1 1 1 1 1 1
1 1 1
7 3
1 1 1 1 1 1 1
1 1 2
7 3
1 1 1 1 1 1 1
1 1 3
7 3
1 1 1 1 1 1 1
1 1 4
7 3
1 1 1 1 1 1 1
1 1 5
7 3
1 1 1 1 1 1 1
1 2 2
7 3
1 1 1 1 1 1 1
1 2 3
7 3
1 1 1 1 1 1 1
1 2 4
7 3
1 1 1 1 1 1 1
1 2 5
7 3
1 1 1 1 1 1 1
1 3 3
7 3
1 1 1 1 1 1 1
1 3 4
7 3
1 1 1 1 1 1 1
1 3 5
7 3
1 ...

output:

-1
-1
-1
-1
4
1 2 3 4
-1
-1
4
1 1 2 3
-1
4
1 2 1 2
-1
-1
-1
-1
-1
4
1 1 1 1
4
1 1 1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4
1 2 3 4
-1
4
1 2 2 3
-1
-1
-1
-1
-1
4
1 1 1 2
4
1 1 2 3
-1
4
1 1 2 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok ok (11550 test cases)

Test #18:

score: 0
Accepted
time: 9ms
memory: 3536kb

input:

16632
7 2
1 1 1 1 1 1 1
1 1
7 2
1 1 1 1 1 1 1
1 2
7 2
1 1 1 1 1 1 1
1 3
7 2
1 1 1 1 1 1 1
1 4
7 2
1 1 1 1 1 1 1
1 5
7 2
1 1 1 1 1 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1 1 3 4 5
6
1 1 3 4 5 6
6
1 3 4 5 6 7
-1
-1
-1
6
1 1 1 2 2 3
6
1 1 1 2 2 4
6
1 1 1 2 4 5
6
1 1 1 4 5 6
6
1 1 4 5...

result:

wrong answer Jury has answer but participant has not (test case 3)