差最后4个点!!求条
查看原帖
差最后4个点!!求条
1266829
cjy2327134004楼主2024/11/3 13:56
#include <bits/stdc++.h>
using namespace std;
int q[5000003],w[10000001],e[10000001];
int main()
{
	int T;
	cin>>T;
	for(int i=1;i<=T;i++)
	{
		long long n,t,m,v=0,b;
		cin>>n>>t>>m;
		for(int a1=1;a1<=n;a1++)
		q[a1]=0; 
		for(int s1=1;s1<=m;s1++)
		w[s1]=0; 
		for(int d1=1;d1<=n;d1++)
		e[d1]=0; 
		for(int o=1;o<=n;o++)
		{
			cin>>q[o];
		}
		for(int p=1;p<=m;p++)
		{
			long long g;
			cin>>g;
			w[g]++;
		}
		int l=0;
		for(int k=1;k<=n;k++)
		{

			long long d=q[k]-2*w[k];
			if(d>0)v++;
			if(d<=0){
				l++;
				b=l;
				e[l]=d;
				
			}
		}
		sort(e+1,e+1+b,greater<int>());
		for(int g=1;g<=b;g++)
		{
			int f=1-e[g];
			t-=f;
			if(t==0)
			{
				v++;
				break;
			}
			if(t<0)break;
			v++;
		}
		cout<<v<<"\n";
	}
}
2024/11/3 13:56
加载中...