-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMINSTOCK.cpp
More file actions
52 lines (42 loc) · 1.07 KB
/
MINSTOCK.cpp
File metadata and controls
52 lines (42 loc) · 1.07 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int c,p;
string s;
map<string, int> mp;
map<int, vector<string> > cp;
for(int it = 1; it <= n; ++it)
{
cin>>c>>s;
if(c!=3) cin>>p;
switch(c)
{
case 1:
case 2:
if(mp.find(s) != mp.end())
{
cp[mp[s]].erase(find(cp[mp[s]].begin(), cp[mp[s]].end(), s));
if(cp[mp[s]].size() == 0)
{
cp.erase(mp[s]);
}
}
mp[s] = p;
cp[p].push_back(s);
break;
case 3:
cout<<cp.begin()->second[0]<<" "<<it<<endl;
s = cp.begin()->second[0];
cp[mp[s]].erase(find(cp[mp[s]].begin(), cp[mp[s]].end(), s));
if(cp[mp[s]].size() == 0)
{
cp.erase(mp[s]);
}
mp.erase(s);
}
//cout<<cp.size()<<" "<<mp.size()<<" *\n";
}
}