We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intq_no,q_type,marks;stringname;map<string,int>m;map<string,int>::iteratorit;cin>>q_no;while(q_no){cin>>q_type;switch(q_type){case1:cin>>name>>marks;it=m.find(name);if(it!=m.end()){m[name]+=marks;}else{m.insert(make_pair(name,marks));}break;case2:cin>>name;m[name]=0;break;case3:cin>>name;it=m.find(name);(it!=m.end())?cout<<m[name]<<endl:cout<<0<<endl;break;}q_no--;}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maps-STL
You are viewing a single comment's thread. Return to all comments →