Advertisement
ekzolot

Untitled

Dec 2nd, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <set>
  4. #include <vector>
  5. using namespace std;
  6. int main(){
  7.     ios::sync_with_stdio(0);
  8.     cin.tie(0);
  9.     cout.tie(0);
  10.     int n;
  11.     cin>>n;
  12.     map <string, set<int>> a;
  13.     map <string, long long> sum;
  14.     for (int i=0; i<n; i++){
  15.         string s;
  16.         cin>>s;
  17.         int t;
  18.         cin>>t;
  19.         if (t==1){
  20.             int x;
  21.             cin>>x;
  22.             if (a[s].count(x)==0){
  23.                 a[s].insert(x);
  24.                 sum[s]+=x;
  25.             }
  26.         }
  27.         if (t==2){
  28.             int x;
  29.             cin>>x;
  30.             if (a[s].count(x)==1){
  31.                 a[s].erase(x);
  32.                 sum[s]-=x;
  33.             }
  34.         }
  35.         if (t==3){
  36.             cout<<sum[s]<<"\n";
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement