QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#810410#9873. Last Chance: Threads of DespairbexiaoheWA 1ms5756kbC++231.3kb2024-12-11 22:08:572024-12-11 22:08:57

Judging History

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

  • [2024-12-11 22:08:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5756kb
  • [2024-12-11 22:08:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define double long double
int t, n, m;

const int N = 5e5 + 10;

int my[N], you[N];

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)cin >> my[i];
	for (int i = 1; i <= m; ++i)cin >> you[i];
	
	sort(my + 1, my + 1 + n);
	sort(you + 1, you + 1 + m);
	
	int idx_my = 1, idx_you = 1, deadline = 1;
	int hurt = 0, judge = 0;
	
	for (int i = 1; i <= n; ++i) {
		if (my[i] == 1) {
			if (judge)continue;
			judge = 1;
			++idx_my;
		}
		--my[i], ++hurt;
	}
	
	if (judge == 0) {
		if (hurt >= you[idx_you]) {
			hurt -= you[idx_you];
			++idx_you;
		}
		else {
			cout << "NO" << endl;
			return;
		}
	}
	
	while (idx_you<=m) {
		while (idx_my <= n && my[idx_my] <= deadline) {
			++idx_my, ++deadline;
		}
		
		if(you[idx_you]<=deadline){
			++deadline;
			++idx_you;
		}
		else if (you[idx_you] <= deadline + hurt) {
			++idx_you;
			hurt -= hurt + deadline - you[idx_you];
		}
		else{
			break;
		}
		
		if (idx_you == m + 1)break;
	}
	
	if (idx_you == m + 1)cout << "YES" << endl;
	else cout << "NO" << endl;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	//srand(time(0));
	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: 1ms
memory: 5756kb

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: 1ms
memory: 5704kb

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: 1ms
memory: 5708kb

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

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
YES
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO

result:

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