-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaps-STL
More file actions
47 lines (45 loc) · 1.16 KB
/
Maps-STL
File metadata and controls
47 lines (45 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main(){
map<string,int>m;
int t;
cin>>t;
while(t--){
int t1,n;
cin>>t1;
switch(t1){
case 1:{
string name;
int marks;
cin>>name>>marks;
map<string,int>::iterator itr=m.find(name);
if(itr==m.end())
m.insert(make_pair(name,marks));
else
itr->second+=marks;
break;
}
case 2:{
string name;
cin>>name;
m.erase(name);
break;
}
case 3:{
string name;
cin>>name;
map<string,int>::iterator itr=m.find(name);
if(itr==m.end()) cout<<"0"<<endl;
else cout<<itr->second<<endl;
break;
}
}
}
return 0;
}