Bootstrap

PTA L1-102 兰州牛肉面

#include <iostream>
#include <map>
using namespace std;
map<int,int> mp;
int n,m,k,x,cnt,flag,num;
double a[105];
double sum; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	while(cin>>m&&m){
		cin>>num;
		mp[m]+=num;
	}
	for(int i=1;i<=n;i++){
		cout<<mp[i]<<endl;
		sum+=mp[i]*a[i];
	}
	printf("%.2lf",sum);
	return 0;
} 

;