QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#810028#9873. Last Chance: Threads of Despairucup-team191#WA 0ms3792kbC++231.0kb2024-12-11 19:13:582024-12-11 19:14:01

Judging History

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

  • [2024-12-11 19:14:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-12-11 19:13:58]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
#define all(a) begin(a),end(a)
#define pb push_back

const int N=1e6 + 500,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int n, m, A[N];

bool cmp(int a, int b) {
	return A[a]  < A[b];
}

void solve() {
	cin >> n >> m;
	vi v, ostalo; 
	int kec = 0;
	for(int i = 0;i < n + m;i++) {
		cin >> A[i];
		if(i < n && A[i] == 1) kec++;
		
		if(i < n) ostalo.pb(A[i]);
		else v.pb(i);
	}
	sort(ostalo.begin(), ostalo.end());
	sort(v.begin(), v.end(), cmp);
	int sad = 0;
	ll vis = 0;
	int j = 0;
	for(int i = 0;i < m;i++) {
		while(j < n && ostalo[j] <= 1 + max(sad, 1)) {
			j++; sad++;
		}
		vis += max(0, A[v[i]] - max(sad++, 1));
	}
	if((!kec && vis < n) || (kec && vis <= n - kec + 1)) cout << "Yes\n";
	else cout << "No\n";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int T; cin >> T;
	for(;T--;) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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

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

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
Yes
Yes
Yes
No
Yes
Yes
No

result:

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