-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path342b.cpp
More file actions
36 lines (34 loc) · 685 Bytes
/
342b.cpp
File metadata and controls
36 lines (34 loc) · 685 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
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++)
typedef long long ll;
int serch(vector<int> p, int target){
int at;
rep(i,p.size()){
if(p[i] == target){
at = i;
break;
}
}
return at;
}
int main(){
int n;
cin >> n;
vector<int> p(100);
rep(i,n){
cin >> p[i];
}
int q;
cin >> q;
rep(i,q){
int a,b;
cin >> a >> b;
int ap = serch(p,a);
int bp = serch(p,b);
int ans = ap < bp ? a : b;
cout << ans << endl;
}
return 0;
}