-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLostGuyRadha.cpp
More file actions
40 lines (34 loc) · 682 Bytes
/
LostGuyRadha.cpp
File metadata and controls
40 lines (34 loc) · 682 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
/* nuttela - Soham Chakrabarti */
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 1e3;
const int inf = INT_MAX;
const int MOD = 1e9 + 7;
int main() {
ll tt; cin >> tt;
while(tt--) {
int n, q;
cin >> n >> q;
int f[n];
set <int> a;
for (int i = 0; i < n; ++i)
{
int x;
cin >> x;
a.insert(x);
f[i] = *--a.end(); //last element of set
}
for (int i = 0; i < q; ++i)
{
int x;
cin >> x;
cout << f[x - 1] << endl;
}
}
return 0;
}