-
Notifications
You must be signed in to change notification settings - Fork 6
/
hdu5233 STK.cpp
73 lines (65 loc) · 1.14 KB
/
hdu5233 STK.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
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<deque>
#include<limits.h>
#include<bitset>
#include<ctime>
#define deb(x) cout<<"#---"<<#x<<"=="<<x<<endl
using namespace std;
const long double PI=acos(-1.0);
const long double eps=1e-6;
const long long maxw=1e17+10;
typedef long long ll;
typedef pair<int,int> pii;
/*head------[@cordercorder]*/
const int maxn=1e5+10;
struct node{
int h;
int id;
bool operator<(const node &a)const{
if(h<a.h)
return 1;
if(h==a.h&&id<a.id)
return 1;
return 0;
}
};
int n,m;
int h[maxn],q[maxn];
set<node> res;
set<node>::iterator it;
int main(void){
node tmp;
int ans;
while(scanf("%d %d",&n,&m)!=EOF){
for(int i=1;i<=n;i++){
scanf("%d",&h[i]);
tmp.id=i;
tmp.h=h[i];
res.insert(tmp);
}
for(int i=1;i<=m;i++){
scanf("%d",&q[i]);
tmp.h=q[i];
tmp.id=-1;
it=res.lower_bound(tmp);
if(it==res.end()||it->h!=q[i]){
puts("-1");
continue;
}
printf("%d\n",it->id);
res.erase(it);
}
}
return 0;
}