QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#811374#9873. Last Chance: Threads of DespairZycK#WA 0ms3788kbC++202.0kb2024-12-12 18:45:592024-12-12 18:46:00

Judging History

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

  • [2024-12-12 18:46:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-12-12 18:45:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

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

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

    int cnt = 0;
    for(int i = 0; i < n; i ++)
    {
        if(a[i] <= i)
        {
            // a[i] = i;
            if(a[i] > 1) cnt ++;
            // if(a[i] > 1 || (a[i] == 1 && i == 0)) cnt ++;
            a[i] = i;
        }
        else
        {
            cnt ++;
            a[i] --;
        }
    }

    // cout << "cnt:" << cnt << endl;
    // for(int i = 0; i < n; i ++) cout << a[i] << " \n"[i == n - 1];
    // for(int i = 0; i < m; i ++) cout << b[i] << " \n"[i == m - 1];

    int i = 0, j = 0, now = 0;
    assert(cnt);
    // while(i < n && j < m && cnt >= 0)
    while(1)
    {
        // cout << i << ' ' << a[i] << ' ' << j << ' ' << b[j] << ' ' << now << endl;
 
        if(j == m)
        {
            cout << "Yes" << endl;
            return;
        }

        if(i < n && a[i] == now) i ++;
        else if(b[j] <= now) j ++;
        else
        {
            // if(now == 4)
            // {
            //     cout << i << ' ' << j << ' ' << cnt << endl;
            // } 

            if(b[j] - now > cnt)
            {
                cout << "No" << endl;
                return;
            }

            cnt -= b[j] - now;
            assert(cnt >= 0);
            j ++;
        }

        now ++;
    }

    // cout << "Yes" << endl;
}

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

    int t = 1;
    cin >> t;
    while(t --)
        solve();

    return 0;
}

/*

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


1
3 2
1 1 4
2 7


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


1
3 1
1 2 2
6



1
7 1
1 1 1 1 1 1 1
9


1
7 1
1 1 1 1 1 1 1
8


1
5 2
2 4 5 6 7
1 6


*/

詳細信息

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3608kb

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
Yes

result:

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

Test #3:

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

input:

4
1 1
1
1
1 1
1
2
1 1
2
1
1 1
2
2

output:

Yes
Yes
Yes
No

result:

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

Test #4:

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

input:

18
1 2
1
1 1
1 2
1
2 1
1 2
1
1 3
1 2
1
2 2
1 2
1
3 2
1 2
1
3 3
1 2
2
1 1
1 2
2
1 2
1 2
2
1 3
1 2
2
2 2
1 2
2
2 3
1 2
2
3 3
1 2
3
1 1
1 2
3
1 2
1 2
3
1 3
1 2
3
2 2
1 2
3
3 2
1 2
3
3 3

output:

Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
No
Yes
No
No
No
No
No

result:

ok 18 token(s): yes count is 7, no count is 11

Test #5:

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

input:

18
2 1
1 1
1
2 1
1 1
2
2 1
1 1
3
2 1
1 2
1
2 1
2 1
2
2 1
2 1
3
2 1
1 3
1
2 1
1 3
2
2 1
3 1
3
2 1
2 2
1
2 1
2 2
2
2 1
2 2
3
2 1
2 3
1
2 1
3 2
2
2 1
2 3
3
2 1
3 3
1
2 1
3 3
2
2 1
3 3
3

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No

result:

ok 18 token(s): yes count is 15, no count is 3

Test #6:

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

input:

525
2 3
1 1
1 1 1
2 3
1 1
1 2 1
2 3
1 1
1 3 1
2 3
1 1
1 4 1
2 3
1 1
5 1 1
2 3
1 1
2 2 1
2 3
1 1
3 1 2
2 3
1 1
1 2 4
2 3
1 1
2 1 5
2 3
1 1
3 3 1
2 3
1 1
4 3 1
2 3
1 1
3 5 1
2 3
1 1
4 4 1
2 3
1 1
4 5 1
2 3
1 1
1 5 5
2 3
1 1
2 2 2
2 3
1 1
2 3 2
2 3
1 1
2 2 4
2 3
1 1
2 5 2
2 3
1 1
3 2 3
2 3
1 1
3 2 4
2 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

wrong answer expected YES, found NO [180th token]