forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCK87MEDI.c
55 lines (46 loc) · 838 Bytes
/
CK87MEDI.c
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
//Author: Rakshit Naidu
#include <stdio.h>
int main(void) {
// your code goes here
int t;
scanf("%d",&t);
while(t--)
{
int n,k;
scanf("%d %d",&n,&k);
int x = n+k;
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int temp=0;
for(int i=1;i<n;i++)
{
for(int j=0;j<n-i;j++)
{
if(a[j] > a[j+1])
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
if(x%2 == 1)
{
int l = (x+1)/2;
printf("%d\n",a[l-1]);
}
else if(x%2==0)
{
int l = x/2;
printf("%d\n",a[l-1]);
}
//for(int i=0;i<n;i++)
//{
// printf("%d",a[i]);
//}
}
return 0;
}