forked from Code-Cube-NITP/Competitive-Programming
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmind_control.cpp
More file actions
Latest commit
executable file
·38 lines (31 loc) · 961 Bytes
/
Copy pathmind_control.cpp
File metadata and controls
executable file
·38 lines (31 loc) · 961 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
// g++ x.cpp -o x && ./x
/*
*/
#include<bits/stdc++.h>
#definefastioios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL)
#defineendl'\n'
#definelllonglongint
usingnamespacestd;
#definepii pair <ll , ll >
#definepb push_back
#definedeb(x) cout << #x << "" << x << endl
#definedeb2(x, y) cout << #x << "" << x << "" << #y << "" << y << endl
#defineloop(x) for (int i = 0; i < x; i++)
#definevin vector<int>
intmain(){
fastio;
int t;
cin >> t;
while (t--) {
int n, m, k;
cin >> n >> m >> k;
vin arr(n);
loop(n) cin >> arr[i];
int first = 0, last = n-1;
loop(k) arr[first] < arr[last] ? first++ : last++;
int temp = m-k-1;
loop(temp) arr[first] > arr[last] ? first++ : last++;
if (arr[first] > arr[last]) cout << arr[first] << endl;
else cout << arr[last] << endl;
}
}