2849: 小A的游戏任务系列一

http://acm.zzuli.edu.cn/problem.php?id=2849

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+10;
const int INX=1e9+10;
int n,m,d,t,k;
int a[N];
ll ans;
int main()
{
    
    
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
    
    
		cin>>d>>t;
		a[d]=t;
	}
	int ma;
	while(m--)
	{
    
    
		cin>>k;
		cin>>ma;
		k--;
		while(k--)
		{
    
    
			cin>>d;
			if(a[d]<a[ma])
			{
    
    
				a[ma]=0;
				ma=d;
			}
			else
				a[d]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
    
    
		ans+=a[i];
//		cout<<i<<" "<<a[i]<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_52341477/article/details/121386321