CCF 202006-2 稀疏向量(100)

#include 
#include 
using namespace std;

typedef long long LL;

map <int, int> mp;

int main()
{	
	ios::sync_with_stdio(false);//cin<
	int n, a, b, index, value;
	LL ans = 0; //此处也需注意~
	cin >> n >> a >> b;
	while(a --)
	{
		cin >> index >> value;
		mp[index] = value;
	}
	while(b --)
	{
		cin >> index >> value;
		if(mp[index] != 0)
		{
			ans += (LL)mp[index] * (LL)value;//这里也有坑!
		}
	}
	cout << ans << endl;
	return 0;
}

参考博客:https://blog.csdn.net/qq_38632614/article/details/107736600

你可能感兴趣的:(CCF)