prompt
string
response
string
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
# cook your dish here t = int(input()) while t>0: n = int(input()) a = list(map(int, input().split())) a.sort() x = n print(abs(a[n]-a[n-1])) t = t -1
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for tt in range(t): n = int(input()) nums = [int(i) for i in input().split()] nums.sort() # print(nums) div = int(nums[n]) - int(nums[n - 1]) print(div)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for j in range(t): n = int(input()) l = list(map(int,input().split())) l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from sys import stdin import math inp = lambda: stdin.readline().strip() t = int(inp()) for _ in range(t): n = int(inp()) ar = [int(x) for x in inp().split()] ar.sort() print(abs(ar[(n*2)//2-1]-ar[(n*2)//2]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.util.*; public class medianClasses { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); int[] ans = new int[t]; for (int i = 0; i < t; i++) { int n = in.nextInt(); int[] skills = new int[2 * n]; for (int j = 0; j ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def solve(array): array = list(sorted(array)) index = len(array) // 2 return array[index] - array[index-1] test_num = int(input()) for test in range(test_num): array_len = int(input()) array = map(int,raw_input().split()) print(solve(array))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) A = list(int(i) for i in input().split()) A.sort() print(abs(A[n - 1] - A[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input("")) ans = [0] * t a1 = [] #potem da bojo vsi test casi for x in range(0,t): n = int(input(""))*2 a1 = a1.clear() a1 = input("").split() a = sorted(a1, key=int) a = [int(z) for z in a] ans[x] = a[int(n/2)] - a[int(n/2-1)] for y in range(0,t): print (ans[y])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int l = 2 * n; int a[l]; for (int i = 0; i < l; i++) { cin >> a[i]; } sort(a, a + l); cout << a[n] - a[n - 1] << endl; } }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() b = a[len(a)//2] c = a[len(a)//2-1] print(b-c)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from sys import stdin, stdout def main(): tc = int(stdin.readline()) for t in range(tc): n = (stdin.readline()) arr = [int(x) for x in stdin.readline().split()] arr.sort() k = int(len(arr)/2) res = abs(arr[k-1] - arr[k]) stdout.write(str(res)+'\n') if __name__ == "__main__": main()
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); int t, n, m; cin >> t; while (t--) { cin >> n; vector<int> arr(2 * n); m = n * 2; for (int i = 0; i < m; i++) cin >> arr[i]; sort(arr.begin(), arr...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in [0]*int(input()): a=(int(input())*2)-1 l=sorted(map(int,input().split())) print(l[0--a//2]-l[a//2])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in xrange(int(raw_input())): n = input() a = map(int, raw_input().split()) a.sort() print a[n] - a[n-1]
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) a = sorted(a) dif = a[n]-a[n-1] print(dif)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for g in range(t): n=int(input()) q=sorted(int(f)for f in input().split()) if n%2: print(q[n]-q[n-1]) else: print(q[n]-q[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#Ashish Sagar #q=1 import math as m q=int(input()) for _ in range(q): n=int(input()) #s=list(input()) #n,k=map(int,input().split()) l=list(map(int,input().split())) l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.util.*; public class div_2_618_b { public static void main(String args[]){ FScanner in = new FScanner(); PrintWriter out = new PrintWriter(System.out); int t = in.nextInt(); while(t-->0) { int n=in.nextInt(); int a[]=in.readArray(2*n); int b[]=new int[n]; int c[]=ne...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; long long a[2 * n]; for (int i = 0; i < (2 * n); i++) { cin >> a[i]; } sort(a, a + (2 * n)); cout << a[n] - a[n - 1] << ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
ans = [] for _ in range(int(input())): n = int(input()) u = list(map(int, input().split())) u.sort() ans.append(u[n] - u[n - 1]) print('\n'.join(map(str, ans)))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.Arrays; import java.util.Scanner; public class TaskA { public static void main(String[] argv) throws Exception { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); int min = Integer.MAX_VALUE; int[] arr = new int[n * 2]; for (int i = ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.Arrays; import java.util.Scanner; public class india { // main function public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n=sc.nextInt(); int[] S = new int[2*n]; ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) while t>0: n=int(input()) arr=list(map(int,input().split(" "))) arr.sort() ans=arr[len(arr)//2]-arr[len(arr)//2 -1] # print(arr) print(ans) t-=1
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.math.*; public class Codeforces { public static String[] longestCommonSubsequence(String str1, String str2,int ind) { // Write your code here. int n=str1.length(); i...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) a.sort() b = len(a)//2 c = b+1 print(a[c-1]-a[b-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
# cook your dish here for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() print(abs(a[(2*n)//2-1] - a[(2*n)//2]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): N = int(input()) A = list(map(int,input().split(" "))) A.sort() print(A[N]-A[N-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
ans = 0 cnt = 0 n = int(input()) for i in range(n): cnt = 0 ans = 0 s = int(input()) f = list(map(int,input().split())) f.sort() print(abs(f[s]-f[s-1]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import sys, itertools, math T = int(sys.stdin.readline()) for _ in range(T): n = int(sys.stdin.readline()) A = [int(i) for i in sys.stdin.readline().strip().split(" ")] A = sorted(A) print(abs(A[n-1] - A[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { static long m; public static long bigmod(long b,long...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n=int(input()) ls=[int(x) for x in input().split()] ls.sort() print(ls[n]-ls[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; public class Main { public static void main(String args[]) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ int n = s.nextInt(); int arr[] = new int[2*n]; for(int i=0;i<2*n;i++){ arr[i] = s.nextIn...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def select(L, j): if len(L) < 10: L.sort() return L[j] S = [] lIndex = 0 while lIndex+5 < len(L)-1: S.append(L[lIndex:lIndex+5]) lIndex += 5 S.append(L[lIndex:]) Meds = [] for subList in S: Meds.append(select(subList, int((len(subList)-1)/2))) med ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int ,input().split())) l = sorted(l) print(l[n] - l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def Input(): tem = input().split() ans = [] for it in tem: ans.append(int(it)) return ans T = Input()[0] for t in range(T): n = Input()[0] a = Input() a.sort() print(abs(a[n-1]-a[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; public class CodeForces1300B{ public static void main(String[] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); for(int i = 0;i<n;i++){ int m = input.nextInt(); m = 2*m; int[] a = new int[m]; for(int j = 0;j<a.length;j++){ a[j] = input.nextInt(); } ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-->0){ int n =scn.nextInt(); n=2*n; int [] arr = new int[n]; for(int i=0;i<arr.len...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
N = int(input()) for _ in range(N): x = int(input()) a = sorted(list(map(int,input().split()))) print(abs(a[x]-a[x-1]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int t, n; const int maxn = 2e5 + 10; int a[maxn]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 0; i < 2 * n; i++) scanf("%d", &a[i]); sort(a + 0, a + 2 * n); cout << a[n] - a[n - 1] << endl; } return 0; }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; import java.util.Arrays; public class FirstCode { public static void main(String [] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); int i=0,j; for(i=0;i<t;i++) { int n=sc.nextInt(); int [] a=new int[2*n]; for(j=0;j<2*...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); PrintWriter out = new PrintWriter(System.out); fo...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for _ in range(t): x=int(input()) a=[int(i) for i in input().split()] a.sort() print(a[x]-a[x-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
'''input 3 1 1 1 3 6 5 4 1 2 3 5 13 4 20 13 2 5 8 3 17 16 ''' for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) i = n - 1 j = n a.sort() min_diff = a[j] - a[i] # while j < 2 * n: # min_diff = min(min_diff, a[j] - a[i]) # i -= 1 # j +...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for _ in range(t): n=int(input()) a=list(map(int,input().split())) a.sort() ans=9999999999999999999999 for i in range(n): j=i rem=2*n-(2*j+1) temp=i+1+rem//2 # print(temp) ans=min(ans,abs(a[i]-a[temp])) a=sorted(a,reverse=True) for i in range(n): j=i rem=2*n-(2*j...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; n *= 2; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); cout << a[n / 2] - a[n / 2 - 1] << endl; } int main() { int t; cin >> t; while (t--) { solve(); } }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) while t > 0: t -= 1 n = int(input()) l = str(input()) duml = l.split() l = [] for i in duml: i = int(i) l.append(i) l.sort(reverse = True) d1 = l[n-1] d2 = l[n] res = d1 - d2 print(res)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def b(): t = int(input()) for i in range(t): n = int(input()) l = [int(x) for x in input().split()] print(solveb(n, l)) def solveb(n, l=None): if l is None: return 0 l.sort() return abs(l[n]-l[n-1]) b()
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import math t = int(input()) for _ in range(t): n = int(input()) a = list(sorted([int(x) for x in input().split()])) print(a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; vector<long long int> v1, v2, v3; string s1, s2, s3; int main() { long long int a, b, c, d, e, f, i, j, k, cnt1 = 0, cnt2 = 0, sum1 = 0, sum2 = 0, chk1 = 0, chk2 = 0, T; cin >> T; for (i = 0; i < T; i++) { cnt1 = 0, sum1 ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import math t = input() for x in range(t): n = input() arr = [int(x) for x in raw_input().split()] arr.sort() print abs(arr[n] - arr[n- 1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> void solve() { std::vector<int> v; int n, a, ans = std::numeric_limits<int>::max(); std::cin >> n; for (int i = 0; i < 2 * n; i++) { std::cin >> a; v.push_back(a); } std::sort(v.begin(), v.end()); int mid1 = std::numeric_limits<int>::max(), mid2 = std::numeric_limits...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; long long add(long long a, long long b) { a += b; if (a >= 1000000007) { a -= 1000000007; } return a; } long long sub(long long a, long long b) { a -= b; if (a < 0) { a += 1000000007; } return a; } long long mul(long long a, long long b) { return (a ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int a[200005]; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); for (int i = 0; i < 2 * n; i++) scanf("%d", &a[i]); sort(a, a + 2 * n); printf("%d\n", a[n] - a[n - 1]); } return 0; }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
n = int(input()) for i in range(n): s = int(input()) t = [int(k) for k in input().split()] t.sort() print(t[s]-t[s-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set;...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; public class B618 { public static void main(String args[]){ Scanner pp = new Scanner(System.in); int t = pp.nextInt(); for(int T=0;T<t;T++){ int n = pp.nextInt(); int[] arr = new int[2*n]; for(int i = 0;i<2*n;i++){ arr[...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
num = int(input()) for _ in range(num): n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) print(a[n-1] - a[n])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; n *= 2; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); cout << abs(a[n / 2 - 1] - a[n / 2]) << "\n"; } int main() { cin.tie(0); ios::sync_with_stdio(0); int test; cin >> te...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; import java.io.*; import static java.util.Arrays.sort; public class Main { static FastReader in=new FastReader(); public static void main(String [] args) { int t=in.nextInt(); while(t-->0){ int n=in.nextInt(),sum=0,ans=0; int a[]=new int [n*2]; for(int i=0;i<2*n;...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; void pr_init() {} void solve() { long long t; cin >> t; for (long long i = 0; i < t; i++) { long long n; cin >> n; n = 2 * n; long long a[n]; for (long long j = 0; j < n; j++) cin >> a[j]; sort(a, a + n); long long ans = 1e10; for (long...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; long long int ara[1000005]; int main() { long long int t; scanf("%lld", &t); for (long long int i = 1; i <= t; i++) { long long int n, c = 0, sum = 0, sum1 = 0, sum2 = 0; scanf("%lld", &n); for (long long int j = 1; j <= 2 * n; j++) { long long int m...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for i in range(t): n=int(input()) l=list(map(int,input().split(" "))) l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int j, i, t, n, *arr, a; cin >> t; for (i = 0; i < t; i++) { cin >> n; arr = (int*)malloc(2 * n * sizeof(int)); for (j = 0; j < 2 * n; j++) cin >> arr[j]; sort(arr, arr + 2 * n); a = (arr[n] - arr[n - 1]); if (a < 0) a = -a; co...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; /* -> Give your 100%, that's it! -> Feynman's Rule To Solve Any Problem: 1. Read the problem. 2. Think About It. ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from math import * t = int(input()) m = [] n = [] for i in range(t): n.append(int(input())) x = list(map(int, input().split())) x.sort() m.append(x) for i in range(t): print(m[i][n[i]]-m[i][n[i]-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.util.*; public class A{ public static void main(String[] args){ Scanner sc =new Scanner (System.in); int t=sc.nextInt(); for(int i=0;i<t;i++){ int n=sc.nextInt(); n*=2; ArrayList<Integer> list=new ArrayList<>(); int mini=(n/2)-...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#Yo... a=int(input()) for i in range (a): b=int(input()) c=list(map(int,input().split())) c.sort() print(c[b]-c[b-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.util.*; import java.lang.Math; public class test1 implements Runnable { private static final int MAX = (int) (1E5 + 5); private static final int MOD = (int) (1E9 + 7); private static final long Inf = (long) (1E14 + 10); static ArrayList<Integer> [] adj; static bool...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
tc=int(input()) for t in range(0,tc): n=int(input()) a=[int(i) for i in input().split(' ')] a.sort() print(a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for _ in range(int(input())): n = int(input()) l = [int(i) for i in input().split()] l.sort(reverse=True) ind = 0 P = [] S = [] for i in l: if (ind % 2) == 0: P.append(i) else: S.append(i) ind += 1 if n % 2 == ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; void solve() { long long i, n; cin >> n; long long a[2 * n]; vector<long long> x, y; for (i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); cout << a[n] - a[n - 1] << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); c...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from collections import defaultdict from math import ceil t = int(input()) for _ in range(t): n = int(input()) a = list(map(int,input().split())) a = sorted(a) print (a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(nam...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for _ in range(t): n=int(input()) A=list(map(int,input().split())) A=sorted(A) print(A[n]-A[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) a = sorted(map(int, input().split())) print(a[n] - a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-->0){ int n = in.nextInt(); int arr[] = new int [2*n]; for (int i=0; i<2*n; ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.time.LocalTime; import java.util.*; import java.util.concurrent.*; import java.util.regex.*; import java.math.*; public class A { public static void main(String[] args) { FastScanner scan = new FastScanner()...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for i in range(t): n = int(input()) a = [int(i) for i in input().split()] a.sort() print(abs(a[n-1]-a[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def solution(n, nav): nav.sort() print(nav[n] - nav[n - 1]) t = int(input()) for i in range(t): n = int(input()) nav = list(map(int, input().split())) solution(n, nav)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for q in range(int(input())): n=int(input()) l=list(map(int,input().split())) l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
N = int(input()) for _ in range(N): n = int(input()) lst = list(map(int, input().split())) lst.sort() # print(*lst) copy = lst # print(n, len(lst)) a = lst[n] b = lst[n - 1] # print(a, b) print(abs(a - b))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
for i in range(int(input())): n = int(input()) a = [int(s) for s in input().split()] a.sort() print(a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import math def change_char(s, p, r): return s[:p]+r+s[p+1:] test = int(input()) while test > 0: n = int(input()) arr = list(map(int, input().split())) arr.sort() print(arr[n] - arr[n-1]) test-=1
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for _ in range(t): n = int(input()) l = [int(x) for x in input().split()] l.sort() print(l[n]-l[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#----Kuzlyaev-Nikita-Codeforces----- #------------03.04.2020------------- alph="abcdefghijklmnopqrstuvwxyz" #----------------------------------- t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input().split())) a.sort() print(a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
# for t in range(int(input())): # s = input() # i, j = 0, 0 # cnt = 0 # ans = float('inf') # dic = {} # while j < len(s): # if len(dic) < 3: # dic[s[j]] = dic.get(s[j], 0) + 1 # # print(j) # # print(dic) # while len(dic) == 3: # ans = min(a...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
from sys import stdin t = int(stdin.readline()) for _ in range(t): n = int(stdin.readline()) v = sorted(list(map(int, stdin.readline().rstrip().split()))) mid1 = v[n] mid2 = v[n-1] print(abs(mid1-mid2))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def f(a): a.sort() return abs(a[len(a) // 2] - a[len(a) // 2 - 1]) t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) print(f(a))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
def solve(a): a.sort() middle = len(a) // 2 return a[middle] - a[middle - 1] if __name__ == "__main__": for i in range(int(input())): n = int(input()) a = [int(x) for x in input().split()] print(solve(a))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n; cin >> n; int a[2 * n]; for (int i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); cout << abs(a[n] - a[n - 1]) << endl; } return 0; }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import sys import math #to read string get_string = lambda: sys.stdin.readline().strip() #to read list of integers get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) ) #to read non spaced string and elements are integers to list of int get_intList_from_str = lambda: list(map(int,list(sys.stdin....
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t=int(input()) for _ in range(t): n=int(input()) l=sorted(list(map(int,input().split()))) a=l[n] b=l[n-1] print(abs(a-b))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#include <bits/stdc++.h> using namespace std; bool cmp(int a, int b) { return a > b; } int a[200000 + 10]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n * 2; i++) cin >> a[i]; sort(a + 1, a + n * 2 + 1, cmp); cout << a[n] - a[n + 1] << endl; } }
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
#!/usr/bin/python3 # @Author : indiewar t = int(input()) while t: t -= 1 n = int(input()) a = list(map(int,input().split())) a.sort() ans = a[n] - a[n-1] print(ans)
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import os import sys from io import BytesIO, IOBase from collections import Counter import math as mt BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import sys import math import heapq import bisect import re from collections import deque from decimal import * from fractions import gcd def YES_NO(flag): if flag: print("AWW") else: print("WAW") def main(): # q = [int(i) for i in sys.stdin.readline().split()] n = int(sys.stdin.re...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
import java.io.*; import java.util.*; public class Equal { public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new FileReader("name.in")); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; ...
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int,input().rstrip().split())) arr = sorted(arr) print(abs(arr[n-1]-arr[n]))
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
mod=1000000007 t=int(input()) while t: t-=1 n=int(input()) a=list(map(int , input().split())) a.sort() print(a[n]-a[n-1])
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}. There are 2n students, the i-th st...
qq = int(input()) for _ in range(qq): n = int(input()) dat = list(map(int, input().split())) dat.sort() print(dat[n]-dat[n-1])