QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808261#9873. Last Chance: Threads of Despairucup-team4975WA 0ms3620kbC++141.7kb2024-12-10 19:06:392024-12-10 19:06:39

Judging History

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

  • [2024-12-10 19:06:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-12-10 19:06:39]
  • 提交

answer

#include <limits>
#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pbk push_back

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
    cerr << setw(4) << #x << ":: "; \
    for (auto i : x)                \
        cerr << i << " ";           \
    cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ostream& operator<<(ostream& out, pii& x)
{
    out << x.fir << " " << x.sec << endl;
    return out;
}

const ll MOD = 998244353;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int N = 200020;


void solve()
{
	int n,m;
	cin>>n>>m;
	vector<int> a(n,0),b(m,0);
	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=n;
	set<int> s;
	for(int i=0;i<n;i++){
		if(a[i]==1)cnt--;
		s.insert(a[i]);
	}
	if(s.count(1))cnt++;
	s.clear();
	for(int i=0;i<n;i++){
		if(a[i]>1)a[i]--;
	}
	if(a[0]==1)a[0]--;
	int p=0,q=0,ddl=0;
	a.pbk(INF);
	b.pbk(INF);
	while(p<n||q<m){
		if(a[p]<=ddl){
			ddl++;
			p++;
		}
		else{
			if(q==m){
				break;
			}
			int d=b[q]-ddl;
			if(d>cnt){
				cout<<"No\n";
				return;
			}
			else{
				cnt-=d;
				ddl++;
			}
			q++;
		}
	}
	cout<<"Yes\n";
	return;
}
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    int T = 1;
    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: 3508kb

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: 3616kb

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: -100
Wrong Answer
time: 0ms
memory: 3620kb

input:

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

output:

Yes
Yes
Yes
Yes

result:

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