Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <set>
- #include <vector>
- using namespace std;
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n;
- cin>>n;
- map <string, set<int>> a;
- map <string, long long> sum;
- for (int i=0; i<n; i++){
- string s;
- cin>>s;
- int t;
- cin>>t;
- if (t==1){
- int x;
- cin>>x;
- if (a[s].count(x)==0){
- a[s].insert(x);
- sum[s]+=x;
- }
- }
- if (t==2){
- int x;
- cin>>x;
- if (a[s].count(x)==1){
- a[s].erase(x);
- sum[s]-=x;
- }
- }
- if (t==3){
- cout<<sum[s]<<"\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement