Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- #include<string>
- using namespace std;
- int main()
- {
- map<string,int>hp;
- map<string,bool>dead;
- int n;
- cin>>n;
- while(n--)
- {
- string atk,def;
- int dmg;
- cin>>atk>>def>>dmg;
- if(dead[atk]==true || dead[def]==true)continue;
- if(hp[atk]==0)hp[atk]=100;
- if(hp[def]==0)hp[def]=100;
- hp[atk]=min(100,hp[atk]+dmg);
- hp[def]-=dmg;
- if(hp[def]<=0)dead[def]=true;
- }
- for(auto i=hp.begin();i!=hp.end();++i)
- cout<<i->first<<' '<<i->second<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment