-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphantuthuk.cpp
More file actions
56 lines (55 loc) · 1.12 KB
/
phantuthuk.cpp
File metadata and controls
56 lines (55 loc) · 1.12 KB
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
//
// created by:DungTD
//
#include <bits/stdc++.h>
#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define base int (1e9+7)
#define ll long long
using namespace std;
int a[1000006] = {0}, b[1000006] = {0};
void solve(){
int m, n, k;
cin >> m >> n >> k;
for (int i=0; i<m; i++) cin >> a[i];
for (int i=0; i<n; i++) cin >> b[i];
int dem = 0;
int x1=0, x2=0;
int res;
while (true) {
if (x1 < m && x2 < n) {
if (a[x1] > b[x2]) {
res = b[x2];
x2++;
dem++;
}
else {
res = a[x1];
x1++;
dem++;
}
}
else {
if (x1==m) {
res = b[x2];
x2++;
dem++;
}
else if (x2==n) {
res = a[x2];
x1++;
dem++;
}
}
if (dem==k) break;
}
cout << res << endl;
}
int main(){
faster();
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}