-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathSolution.cpp
More file actions
38 lines (36 loc) · 817 Bytes
/
Solution.cpp
File metadata and controls
38 lines (36 loc) · 817 Bytes
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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main() {
int n;
cin >> n;
map<string,int> m;
for (int i = 0; i < n; i++) {
int type, mark;
string name;
cin >> type >> name;
if (type == 1) {
cin >> mark;
auto it = m.find(name);
if (it != m.end()) {
m[name] += mark;
} else {
m[name] = mark;
}
} else if (type == 2) {
m.erase(name);
} else if (type == 3) {
auto it = m.find(name);
if (it != m.end()) {
cout << m[name] << "\n";
} else {
cout << "0\n";
}
}
}
return 0;
}