elephantsarecool

map3

May 28th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.   map<string,int>hp;
  8.   map<string,bool>dead;
  9.   int n;
  10.   cin>>n;
  11.   while(n--)
  12.   {
  13.     string atk,def;
  14.     int dmg;
  15.     cin>>atk>>def>>dmg;
  16.     if(dead[atk]==true || dead[def]==true)continue;
  17.     if(hp[atk]==0)hp[atk]=100;
  18.     if(hp[def]==0)hp[def]=100;
  19.     hp[atk]=min(100,hp[atk]+dmg);
  20.     hp[def]-=dmg;
  21.     if(hp[def]<=0)dead[def]=true;
  22.   }
  23.   for(auto i=hp.begin();i!=hp.end();++i)
  24.     cout<<i->first<<' '<<i->second<<endl;
  25.   return 0;
  26. }
Add Comment
Please, Sign In to add comment