-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmapstl.cpp
More file actions
60 lines (54 loc) · 1.08 KB
/
Copy pathmapstl.cpp
File metadata and controls
60 lines (54 loc) · 1.08 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
48
49
50
51
52
53
54
55
56
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
map<string,int> m;
int n;
cin>>n;
int mark;
int q;
string name;
for(int i=0;i<n;i++)
{
cin>>name;
cin>>q;
if(q==1)
{
cin>>mark;
map<string,int>::iterator itr;
itr = m.find(name);
if(itr==m.end())
{
m.insert(make_pair(name,mark));
}
else
{
m[name]+=mark;
}
}
else if(q==2)
{
m.erase(name);
}
else if(q==3)
{
map<string,int> :: iterator itr;
itr=m.find(name);
if(itr==m.end())
{
cout<<0<<endl;
}
else
{
cout<<m[name]<<endl;
}
}
}
return 0;
}