QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809973#9873. Last Chance: Threads of DespairYUKIIWA 0ms3628kbC++142.0kb2024-12-11 18:47:092024-12-11 18:47:11

Judging History

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

  • [2024-12-11 18:47:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-12-11 18:47:09]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll = unsigned long long;

int main() {
    char const* yes = "Yes", * no = "No";
    int n, size1, size2, temp;
    
    cin >> n;
    while (n--) {
        cin >> size1 >> size2;
        vector<int> vec1, vec2;
        for (int i = 0; i < size1; ++i) {
            cin >> temp;
            vec1.push_back(temp);
        }
        for (int i = 0; i < size2; ++i) {
            cin >> temp;
            vec2.push_back(temp);
        }

        sort(vec1.begin(), vec1.end());
        sort(vec2.begin(), vec2.end());

        int hurt = size1;
        int deadline = 0;
        int idx1 = 0, idx2 = 0;
        while (idx1 < size1 && vec1[idx1] == 1) {
            --hurt, ++deadline, ++idx1;
        }
        while (idx1 < size1 && vec1[idx1] <= deadline) {
            ++idx1, ++deadline;
        }
        while (idx2 < size2 && vec2[idx2] <= deadline) {
            ++idx2, ++deadline;
        }
        if (idx2 == size2) {
            cout << yes << endl;
            continue;;
        }
        if (idx1) {
            --vec2[idx2];
        }

        int curIdx1 = idx1;
        while (hurt) {
            while (idx1 < size1 && vec1[idx1] <= deadline) {
                ++idx1, ++curIdx1, ++deadline;
            }
            while (idx2 < size2 && vec2[idx2] <= deadline) {
                ++idx2, ++deadline;
            }
            if (idx2 < size2 && idx1 < size1 && curIdx1 < size1) {
                --vec1[curIdx1], --vec2[idx2], ++curIdx1;
            }
            --hurt;
        }
        while (idx1 < size1 && vec1[idx1] <= deadline) {
            ++idx1, ++curIdx1, ++deadline;
        }
        while (idx2 < size2 && vec2[idx2] <= deadline) {
            ++idx2, ++deadline;
        }
        if (idx2 == size2) {
            cout << yes << endl;
        } else {
            cout << no << endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
No
Yes

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

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

input:

3
7 1
1 1 1 1 1 1 1
9
5 2
3 4 5 6 7
1 6
5 3
3 4 5 6 7
1 5 7

output:

No
No
No

result:

wrong answer expected YES, found NO [3rd token]