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...
import sys input = sys.stdin.readline Q = int(input()) Query = [] for _ in range(Q): N = int(input()) A = list(map(int, input().split())) Query.append((N, A)) for N, A in Query: 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...
#include <bits/stdc++.h> using namespace std; void solve() { int n, tmp; cin >> n; vector<int> v(2 * n); for (int i = 0; i < 2 * n; ++i) { cin >> v[i]; } sort(v.begin(), v.end()); cout << v[n] - v[n - 1] << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin...
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 AssigningToClasses { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); if(n==1) { int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(Math.abs(a-b)); } else { int ...
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 = __import__('sys').stdin.readline MIS = lambda: map(int,input().split()) for TEST in range(int(input())): n = int(input()) arr = sorted(MIS()) 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...
t = int(input()) for k in range(t): n = int(input()) arr = sorted(list(map(int, input().split()))) first = arr[::2] second = arr[1::2] if len(first) % 2 and not len(second) % 2: first = [second[0]] + first[:] + [second[-1]] second = second[1:-1] elif not len(first) % 2 and len(se...
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().split())) arr.sort() if n==1: print(arr[1]-arr[0]) else: print(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> using namespace std; int main() { long int t, n, i; cin >> t; while (t--) { cin >> n; long int arr[n + n]; for (i = 0; i < n * 2; i++) cin >> arr[i]; sort(arr, arr + n + n); cout << arr[n] - arr[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 i in range(int(input())): n = int(input()) n-=1 arr = list(map(int,input().split())) arr.sort() # print("s",arr[n],'ss',arr) 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...
import os from io import BytesIO, IOBase import sys from bisect import bisect_right,bisect_left def main(): for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) a.sort() print(a[n]-a[n-1]) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = ...
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 n, arr[100005], odd1[100005], odd2[100005], x = 0, y = 0, sum = 0; cin >> n; for (int i = 0; i < 2 * n; i++) cin >> arr[i]; sort(arr, arr + 2 * n); if (n % 2 != 0) { for (int i = 0; i < 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.*; public class Main { public static void main (String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-->0) { int n = in.nextInt() * 2; int a[] = new int[n]; for (int i=0; i<n; i++) { a[i] = in.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...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, x; cin >> t; vector<int> v; while (t-- > 0) { cin >> n; n *= 2; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } sort(v.begin(), v.end()); int l, r; r = n / 2; l = n / 2 - 1; int ans = v...
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 B { void solve(FastIO io) { int n = io.nextInt(); Integer[] a = new Integer[2*n]; for (int i = 0; i < 2 * n; i++) { a[i] = io.nextInt(); } Arrays.sort(a); io.println((Math.abs(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 sys import math import heapq import collections def inputnum(): return(int(input())) def inputnums(): return(map(int,input().split())) def inputlist(): return(list(map(int,input().split()))) def inputstring(): return([x for x in input()]) def inputstringnum(): return([ord(x)-ord('a') for x in...
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()) xs = sorted(map(int, input().split())) print(abs(xs[n] - xs[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...
#fin = open ('input.txt', 'r') #fout = open ('output.txt', 'w') from sys import stdin, stdout insize = int(stdin.readline().replace("\n","")) asize = [] a1 = [] for x in range(insize): asize = stdin.readline().replace("\n","") a1.append(stdin.readline().replace("\n","").split(" ")) for item in a1: for x ...
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.Scanner; import java.util.Arrays; public class B{ static Scanner sc = new Scanner(System.in); static int n,t; static int[] arr; public static void main(String[] args){ for(int t = sc.nextInt(); t > 0; --t){ n = sc.nextInt(); arr = 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...
import java.util.*; public class AssigningToClasses_1300B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int arr[] = new int[2*n]; for(int i = 0; i<2*n; i++) { arr[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...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i; cin >> t; while (t--) { cin >> n; int arr[2 * n + 1]; for (i = 0; i < 2 * n; i++) { cin >> arr[i]; } sort(arr, arr + 2 * n); cout << (arr[n] - arr[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...
#include <bits/stdc++.h> using namespace std; int main() { int T = 1; cin >> T; while (T--) { 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 << 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...
kl=int(input()) for l in range(kl): 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...
def solve(n, a): a.sort() return a[n] - a[n - 1] def main(): tc = int(input()) for _ in range(tc): n = int(input()) a = [int(x) for x in input().split()] print(solve(n, a)) 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() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n * 2 + 1]; for (int c = 0; c < n * 2; c++) cin >> arr[c]; sort(arr, arr + n * 2); vector<int> prima, doi; for (int c = 0; c < n * 2; c++) if (c % 2 == 0) pr...
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; const long long INF = 1e7; const long long N = 1e5 + 7; const long long mod = 1e9 + 7; const long double eps = 1E-7; long long a = 1, n, b = 2, c = 1, d, cnt, m, ans, sum; string s, s1, s2; multiset<char> st; long long used[N]; vector<int> v, v1; int main() { ios_base::sy...
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()) k = 2*n arr = [int(x) for x in input().split()] arr.sort() l = int(len(arr)//2) print(arr[l]-arr[l-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()) arr=sorted(list(map(int,input().split()))) print(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...
import java.util.*; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); int[] a = new int[2*n]; for(int i=0;i<2*n;i++) { a[i] = sc.nextInt(); } Arrays.sort(a); System.out.println(...
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 bla in range(t): n = int(input()) lis = list(map(int, input().split())) lis = sorted(lis) print(lis[n]-lis[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 sys import os import time import collections from collections import Counter, deque import itertools import math import timeit import random ######################### # imgur.com/Pkt7iIf.png # ######################### def sieve(n): if n < 2: return list() prime = [True for _ in range(n + 1)] p = ...
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 tc, n, tmp; cin >> tc; while (tc > 0) { cin >> n; n *= 2; vector<int> v; while (n > 0) { cin >> tmp; v.push_back(tmp); n--; } sort(v.begin(), v.end()); cout << (v[(v.size() / 2)] - v[(v.size() / 2) - 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()) while t: t -= 1 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 random t = int(input()) while t : t -= 1 n = int(input()) a = list(map(int,input().split())) a.sort() print(abs(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()) a = sorted(map(int, input().split())) ans = a[-1] - a[0] for i in range(n): x = n * 2 - (i * 2 + 1) y = x // 2 ans = min(ans, a[i + y + 1] - a[i]) 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...
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { BufferedReader bf = new BufferedReader(new ...
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; const long long N = 2e5 + 10; int a[N]; int main() { int sssssssssssssssss; cin >> sssssssssssssssss; while (sssssssssssssssss--) { int ggggggggggggggggggg; cin >> ggggggggggggggggggg; for (int i = 1; i <= 2 * ggggggggggggggggggg; i++) cin >> a[i]; sor...
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...
# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code def main(): t = int(input()) for _ in range(t): n = int(input()) a = list(map(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...
#include <bits/stdc++.h> using namespace std; int t, n, a[200005]; int main() { cin >> t; for (int j = 1; j <= t; j++) { cin >> n; for (int i = 1; i <= n * 2; i++) cin >> a[i]; sort(a + 1, a + 2 * n + 1); cout << a[n + 1] - a[n] << '\n'; } 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...
result = str() for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() local_result = abs( a[n - 1] - a[n] ) result += f'\n{local_result}' print(result.strip())
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; const int maxN = 2e5 + 11; const long long oo = 1e17 + 11; int tcases = 1; char ch; int readInt() { bool fl = 0; while (ch = getchar(), ch != '-' && (ch < '0' || ch > '9')) ; if (ch == '-') { fl = 1; while (ch = getchar(), ch < '0' || ch > '9') ; }...
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()) arr = list(map(int, input().split())) arr.sort() ans = abs(arr[n-1]-arr[n]) 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...
t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input().split())) a.sort() l=[] r=[] if(n%2!=0): for j in range(len(a)): if(j%2==0): l.append(a[j]) else: r.append(a[j]) # print(l,r) print(abs(l[n//2]-r[n//2])) else: for j in range(len(a)-1): if(j%2==0): l.append(a[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...
sp = lambda: list(map(int, input().split())) si = lambda: int(input()) TESTCASES = int(input()) result=[] for tc in range(TESTCASES): n=si() a=sorted(sp()) result.append(str(a[n] - a[n-1])) print("\n".join(result))
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=sorted(a) print(abs(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.util.Arrays; import java.util.Scanner; //Find MIN for ax+by = C public class brackets { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (s.hasNextInt()) { int n=s.nextInt(); int[] arr = new int[2*n]; for (int i=0;i<2*n;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()) abc=sorted(list(map(int, input().split()))) print(abc[n]-abc[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...
test_cases = int(input()) for _ in range(test_cases): n = int(input()) a = list(map(int, input().split())) sorted_a = sorted(a) mid = len(a) // 2 prev_mid = mid-1 print(sorted_a[mid]-sorted_a[prev_mid])
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 main(): n = int(input()) a = list(map(int, input().split())) a = sorted(a) print(a[len(a)//2] - a[len(a)//2 - 1]) if __name__ == "__main__": t = int(input()) for i in range(t): 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...
import math for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) l=sorted(l) po=len(l)//2 if(n==1): print(l[1]-l[0]) else: print(abs(l[po]-l[po-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())): n=int(input()) a=[int(v) for v in input().split()] a.sort() print(abs(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 i in range(int(input())): n=int(input()) a=list(map(int,input().split())) a.sort() if n==1: print(abs(a[0]-a[1])) else: n = (2*n)-1 n = n//2 print(abs(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...
n=int(input()) for i in range(n): p=int(input()) q=list(map(int,input().split())) q.sort() print(abs(q[p-1]-q[p]))
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...
/* * * Date: 07 September 2019 * Time: 01:03:00 */ import java.io.*; import java.util.*; public class assign { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>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...
#include <bits/stdc++.h> long double pi = acos(-1.0); const int mod = 1e9 + 7; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20); cout.setf(ios::fixed); long long t; cin >> t; for (int(ha) = 0; (ha) < t; (ha)++) { int n; cin >> n; vect...
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()) x=0 a=[int(i)for i in input().split()] a=sorted(a) x=abs(a[n-1]-a[n]) print(x)
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 = list(map(int,input().split())) l.sort() x = len(l)//2 y = x-1 print(abs(l[x]-l[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...
import java.util.Arrays; import java.util.Scanner; public class AssigningTheClasses { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int test = scanner.nextInt(); scanner.nextLine(); for (int t = 0; t < test; t++) { int n = scanner.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...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int,input().split())) a.sort() j = (2*n)//2; i = j-1 print(abs(a[i]-a[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 k in range(t): n = int(input()) mas = list(map(int, input().split())) mas.sort() print (mas[n] - mas[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.Arrays; import java.util.Scanner; public class skillClass { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while (t-- >0) { int n=sc.nextInt(); int a[]=new int[2*n]; for(int i=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...
from __future__ import print_function # for PyPy2 from collections import Counter, OrderedDict from itertools import permutations as perm from collections import deque from sys import stdin from bisect import * from heapq import * import math g = lambda : stdin.readline().strip() gl = lambda : g().split() gil = la...
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.*; public class Codechef { PrintWriter out; StringTokenizer st; BufferedReader br; class Pair implements Comparable<Pair> { int f; int s; Pair(int t, int r) { f = t; s = r; } public int compareTo(Pair p) ...
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()) k=sorted(list(map(int,input().split()))) print(k[n]-k[(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 v in range(t): n=int(input()) li=list(map(int,input().split(" "))) li.sort() print(li[n]-li[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.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { private static final String NO = "NO"; private static final String YES = "YES"; InputStream is; PrintWriter...
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 codeforce; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class assignToClass { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Inte...
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.math.*; public class a{ public static void main(String args[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); while(t-->0) { int n=Integer.parseInt(br.readLine()); 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...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int a[]=new int[2*n]; for (int i=0;i<2*n;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...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 4 15:29:49 2020 @author: dennis """ import atexit import io import sys _INPUT_LINES = sys.stdin.read().splitlines() input = iter(_INPUT_LINES).__next__ _OUTPUT_BUFFER = io.StringIO() sys.stdout = _OUTPUT_BUFFER @atexit.register def write(): ...
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 t = int(input()) for _ in range(t): n=int(input()) l = list(map(int,sys.stdin.readline().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...
""" NTC here """ import sys inp= sys.stdin.readline input = lambda : inp().strip() flush= sys.stdout.flush # import threading # setrecursionlimit(10**6) # threading.stack_size(2**26) def iin(): return int(input()) def lin(): return list(map(int, input().split())) # range = xrange # input = raw_input def 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...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() if n == 1: print(a[1] - a[0]) continue x, y, z = a[n - 2], a[n - 1], a[n] print(min(z - x, z - 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...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) arr.sort() print(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...
def find_absme (n,a): a = sorted(a) return abs(a[n]-a[n-1]) t = int(input()) ans = [] for x in range(t): n = int(input()) a = list(map(int,input().split())) ans.append(find_absme(n,a)) for y in ans: print (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...
t=int(input()) for you in range(t): n=int(input()) l=input().split() li=[int(i) for i in l] li.sort() mina=[] print(li[n]-li[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 i in range(int(input())): n = int(input()) lst = sorted([int(x) for x in input().split()]) print(lst[n]-lst[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.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; public class Main { FastScanner in; PrintWriter out; public static void main(String[] args) throws Exception { (new Main()).run(); } private void run() thro...
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 n; cin >> n; for (int x = 0; x < n; x++) { int m; cin >> m; int arr[m * 2]; for (int x = 0; x < m * 2; x++) { cin >> arr[x]; } sort(arr, arr + m * 2); cout << arr[m * 2 / 2] - arr[m * 2 / 2 - 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...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; for (long long i = 0; i < t; i++) { long long n; cin >> n; long long a[n * 2]; for (long long i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + n * 2); cout << a[n] - a[n - 1] << endl; } retur...
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); ; long long int t, n, i, a[200005]; cin >> t; while (t--) { cin >> n; for (i = 0; i < 2 * n; i++) cin >> a[i]; sort(a, a + 2 * n); 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 tc in range(int(input())): n=int(input()) l=list(map(int,input().split())) l.sort() print(abs(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...
t = int(input()) for _ 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...
import sys from functools import reduce def solution(arr, n): arr.sort() print(arr[n] - arr[n-1]) for line in sys.stdin: t = int(line) break p = 1 for line in sys.stdin: if p == 1: n = int(line) else: arr = [int(x) for x in line.split()] solution(arr, n) p *...
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 argc, char const *argv[]) { int t; cin >> t; while (t--) { long long n; cin >> n; long long arr[2 * n]; for (int i = 0; i < 2 * n; i++) cin >> arr[i]; sort(arr, arr + 2 * n); cout << abs(arr[n] - arr[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 bisect import os from collections import Counter import bisect from collections import defaultdict import math import random import heapq as hq from math import sqrt import sys from functools import reduce, cmp_to_key from collections import deque import threading from itertools import combinations from io impor...
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 CR618B { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); int[] a = new int[2 * n]; for (int i = 0; i < 2 * n; i++) { a[i] = s.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...
#include <bits/stdc++.h> const double pi = acos(-1.0); using namespace std; long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } long long int lcm(long long int a, long long int b) { return a * b / gcd(a, b); } void solve() { long long int n; cin >> n; long long int 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 range(int(input())): n=int(input()) x=sorted([int(n) for n in input().split()]) print(x[n]-x[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 t=int(input()) while t>0: t-=1 n=int(input()) a=list(map(int,input().split())) a.sort() median=a[n]-a[n-1] print(median)
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()) l1=[] for k in range(t): n=int(input()) l2=[int(a) for a in input().split()] l2.sort() l1.append(l2[n]-l2[n-1]) for j in range(t): print(l1[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...
# HEY STALKER for _ in range(int(input())): n = int(input()) n *= 2 l = list(map(int, input().split())) l.sort() x = l[(n//2)-1] y = l[n//2] print(abs(x-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...
import sys import math def read_line(): return sys.stdin.readline()[:-1] def read_int(): return int(sys.stdin.readline()) def read_int_line(): return [int(v) for v in sys.stdin.readline().split()] t = read_int() for i in range(t): n = read_int() a = read_int_line() cnt= 1e9 a.sort() print(abs(a[len(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...
/*============================================== Name : Shadman Shariar || Email : shadman.shariar@northsouth.edu || University : North South University (NSU) || Facebook : shadman.shahriar.007 || ==============================================*/ import java.util.*; import...
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 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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, t, i, x; cin >> t; while (t--) { cin >> n; long long int a[2 * n]; for (i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); cout ...
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, n): a.sort() ans = 1000000009 for i in range(0, 2 * n): if i < n: ans = min(ans, a[n] - a[i]) elif i > n: ans = min(ans, a[i] - a[2 * n - i]) return ans if __name__ == '__main__': t = int(input()) for i in range(t): n = int(input()) ...
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...
''' sort the list find the n's and n + 1's element return the diff ''' def solve(lst): lst.sort() n = len(lst) return lst[n//2] - lst[n//2-1] m = input() for _ in range(int(m)): n = input() lst = list(map(int, input().split())) print(solve(lst))
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()) a=list(map(int,input().split())) a.sort() c=abs(a[s]-a[s-1]) print(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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class test2 { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br=new BufferedReader(new InputStreamReader...
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=[int(x) for x in input().split(" ")] l.sort() d=l[n]-l[n-1] print(d)
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.lang.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int a[]=new int[2*n]; for(int i=0;i<2*n;i++) a[i]=sc.nextInt(); Arrays.sort(a); System....