-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmazonStore.cpp
93 lines (87 loc) · 1.72 KB
/
AmazonStore.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int>pos,mf,mi;
int n;
cin>>n;
int m;
cin>>m;
for(int i=0;i<n;i++){
int k;
cin>>k;
pos.push_back(k);
}
for(int i=0;i<m;i++){
int k;
cin>>k;
mf.push_back(k);
}
for(int i=0;i<m;i++){
int k;
cin>>k;
mi.push_back(k);
}
map<int,int>mapping;
for(int i=0;i<pos.size();i++){
mapping[pos[i]]=pos[i];
}
for(int i=0;i<m;i++){
if(mapping.find(mf[i])!=mapping.end()) {
mapping.erase(mf[i]);
mapping[mi[i]]=mi[i];
}
}
vector<int>ans;
for(auto i : mapping){
ans.push_back(i.first);
}
for(auto i : ans){
cout<<i<<" ";
}
cout<<endl;
return 0;
}// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int>pos,mf,mi;
int n;
cin>>n;
int m;
cin>>m;
for(int i=0;i<n;i++){
int k;
cin>>k;
pos.push_back(k);
}
for(int i=0;i<m;i++){
int k;
cin>>k;
mf.push_back(k);
}
for(int i=0;i<m;i++){
int k;
cin>>k;
mf.push_back(k);
}
map<int,int>mapping;
for(int i=0;i<pos.size();i++){
mapping[pos[i]]=pos[i];
}
for(int i=0;i<m;i++){
if(mapping.find(mf[i])!=mapping.end()) {
mapping.erase(mf[i]);
mapping[mi[i]]=mf[i];
}
}
vector<int>ans;
for(auto i : mapping){
ans.push_back(i.first);
}
for(auto i : ans){
cout<<i<<" ";
}
cout<<endl;
return 0;
}