-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path799B.cpp
More file actions
62 lines (50 loc) · 1018 Bytes
/
799B.cpp
File metadata and controls
62 lines (50 loc) · 1018 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int price[n],a[n],b[n];
for(int i=0;i<n;i++){
cin>>price[i];
}
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
set<int> one;
set<int> two;
set<int> three;
for(int i= 0;i<n;i++)
{
if(a[i] == 1) one.insert(price[i]);
else if(a[i] == 2) two.insert(price[i]);
else if(a[i] == 3) three.insert(price[i]);
if(b[i] == 1) one.insert(price[i]);
else if(b[i] == 2) two.insert(price[i]);
else if(b[i] == 3) three.insert(price[i]);
}
set<int>::iterator it1 = one.begin();
set<int>::iterator it2 = two.begin();
set<int>::iterator it3 = three.begin();
int m;
cin>>m;
int choice;
for(int i= 0;i<m;i++)
{
cin>>choice;
int p;
if(choice == 1)
{p = *it1;}
else if(choice == 2){ p = *it2;}
else if(choice == 3){ p = *it3;}
else p = -1;
one.erase(p); it1 = one.begin();
two.erase(p); it2 = two.begin();
three.erase(p); it3 = three.begin();
if(p == 0) cout<<"-1"<<" ";
else cout<<p<<" ";
}
}