-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCTDL058.cpp
48 lines (48 loc) · 1009 Bytes
/
SCTDL058.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
/**
* @file SCTDL058.cpp
* @author long ([email protected])
* @brief Find the k-th element after merging 2 arrays with ascending order.
* @version 0.1
* @date 2023-06-10
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n, m, k;
cin >> n >> m >> k;
int a[n], b[m], p1 = 0, p2 = 0, ans;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < m; i++)
cin >> b[i];
while (k--)
{
if (p1 == n - 1)
ans = b[p2++];
if (p2 == m - 1)
ans = a[p1++];
if (a[p1] < b[p2])
{
ans = a[p1];
p1++;
}
else
{
ans = b[p2];
p2++;
}
}
cout << ans << endl;
}
}