7 Dances (Easy version)

image
image

#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,m;
	cin>>n>>m;
	vector<int>a;
	vector<int>b;
	a.push_back(1); 
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		a.push_back(x);
	}
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		b.push_back(x);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(int i=0;i<n;i++){
		auto t=upper_bound(b.begin(),b.end(),a[i]);
		if(t!=b.end()){
			b.erase(t);
		}else{
			int p=b.size();
			int ans=max(n-i,p);
			cout<<ans<<"\n";
			return;
		}
	}
	cout<<0<<"\n";
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	cin>>t;
	for(int i=1;i<=t;i++)solve();
	return 0;
} 
posted @ 2024-01-09 20:54  yufan1102  阅读(3)  评论(0编辑  收藏  举报