#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int n,m,money; string name1,name2; cin>>n; map<string,int> name_money; string name[n]; for(int i=0;i<n;i++){ cin>>name[i]; } for(int i=0;i<n;i++){ cin>>name1; cin>>money>>m; for(int j=0;j<m;j++){ cin>>name2; name_money[name2]=name_money[name2]+money/m; if(m!=0){ name_money[name1]=name_money[name1]-money+money%m; } } } for(int i=0;i<n;i++){ cout<<name[i]<<" "<<name_money[name[i]]<<endl; } return 0; }
标签:name,int,money,送礼物,name2,name1,string From: https://www.cnblogs.com/hanxuyao/p/17500122.html