QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#838802#9873. Last Chance: Threads of DespairTangWKWA 0ms3608kbC++202.4kb2024-12-31 23:15:032024-12-31 23:15:05

Judging History

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

  • [2024-12-31 23:15:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-12-31 23:15:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1), b(m + 1);
    priority_queue<int, vector<int>, greater<int>> q1, q2;
    int bump = 0, damage = 0;
    bool flag = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > 1) {
            ++damage;
        }else if (a[i] == 1) {
            if (!flag) {
                ++damage;
                flag = true;
            }
        }
        q2.push(a[i] - 1);
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
        q1.push(b[i]);
    }
    while (damage > 0) {
        flag = false;
        while (!q1.empty() && q1.top() <= bump) {
            q1.pop();
            ++bump;
            flag = true;
        }
        // cout << "!!!\n";
        while (!q2.empty() && q2.top() <= bump) {
            q2.pop();
            ++bump;
            flag = true;
        }
        if (!q1.empty()) {
            // int tmp_damage = min(damage, q1.top() - bump);
            if (q1.top() <= bump) {
                q1.pop();
                ++bump;
                continue;
                flag = true;
            }else {
                // int tmp = min(damage, q1.top() - bump);
                if (q1.top() - bump > damage) {
                    break;
                }
                damage -= q1.top() - bump;
                q1.pop();
                // damage -= tmp;
                // q1.push();
            }
        }
        if (!flag) {
            break;
        }
    }
    while (!q1.empty() && !q2.empty()) {
        flag = false;
        while (!q1.empty() && q1.top() <= bump) {
            ++bump;
            q1.pop();
            flag = true;
        }
        while (!q2.empty() && q2.top() <= bump) {
            ++bump;
            q2.pop();
            flag = true;
        }
        if (!flag) {
            break;
        }
    }
    while (!q1.empty() && q1.top() <= bump) {
        ++bump;
        q1.pop();
    }
    if (!q1.empty()) {
        cout << q1.top() << "??\n";
        cout << bump << "Qwq\n";
        cout << damage << "??\n";
        cout << "No\n";
    }else {
        cout << "Yes\n";
    }
    return;
}
int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3608kb

input:

3
3 2
1 1 4
2 6
3 2
1 1 4
2 7
2 1
100 100
2

output:

Yes
7??
4Qwq
2??
No
Yes

result:

wrong output format YES or NO expected, but 7?? found [2nd token]