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...
ans = [] for t in range(int(input())): n = int(input()) nums = [int(i) for i in input().split()] nums.sort() ans.append(str(abs(nums[n] - nums[n - 1]))) print('\n'.join(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 tt in range(t): n = int(input()) x = list(input().split()) a = [] for i in range(2*n): a.append(int(x[i])) a.sort() #print(a) c = abs(a[n-1]-a[n]) 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...
t = int(input()) for i in range(t) : n = int(input()) array = list(map(int, input().split(" "))) array = sorted(array) print(array[n] - array[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()) p = list(map(int, input().split())) p.sort() half = int(len(p) / 2) print(p[half] - p[half-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); long long n, k, m, t; cin >> t; while (t--) { cin >> n; long long a[2 * n + 5]; for (long long i = 1; i <= n * 2; i++) cin >> a[i]; sort(a + 1, a + 2 * n + 1); cout << 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.io.*; import java.util.*; public class CP { static long startTime; static long endTime; static Boolean [] prime ; static int M=(int)1e9+7; static int MAX=Integer.MAX_VALUE; static int MIN=Integer.MIN_VALUE; static int SIZE = (int)1e9*2; static class FastReader{ Buffer...
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.Arrays; import java.util.List; import java.util.StringTokenizer; public class realfast implements Runnable { private static final int INF = (int) 1e9; long in= (long)Math.pow(10,9); public void solve() throws IOException { int t ...
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; for (int i = 0; i < t; ++i) { int n; cin >> n; long long int a[2 * n]; for (long long int i = 0; i < 2 * n; ++i) { cin >> a[i]; } sort(a, a + (2 * n)); if (n == 1) { 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...
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import defaultdict from math import factorial as f from fractions import gcd as g T = int (raw_input ()) for _ in range(T): N = 2 * int (raw_input ()) l = [int(i) for i in raw_input().split()] l.sort() def med(i): if i < N / 2: 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...
#Pye from sys import stdin, stdout from os import path if path.exists('inp.txt'): stdin = open("inp.txt", "r") q = int(stdin.readline()) for _ in range(q): n = int(stdin.readline()) a = list(map(int, stdin.readline().split())) a.sort() cnt, b, c = 0, [], [] b.append(0) c.append(0) for ...
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()) a=[] for i in range(t): n=int(input()) b=list(map(int,input().split())) a.append([n,b]) for i in a: n=i[0] j=i[1] j.sort() print(j[n]-j[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 Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); for(int u=0; u < t; u++) { int n = input.nextInt(); Integer[] a = new Integer[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...
te = int(input()) while te > 0: te -= 1 n = int(input()) skills = list(map(int, input().split())) skills.sort() ans = abs(skills[n] - skills[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...
res = '' for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) if n == 1: res += str(abs(a[0] - a[1])) + '\n' else: a.sort() res += str(a[n] - a[n - 1]) + '\n' 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...
I =lambda:int(input()) M =lambda:map(int,input().split()) LI=lambda:list(map(int,input().split())) for _ in range(I()): n=I() a=LI() 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 java.util.*; import java.io.*; public class Codeforces { static InputReader in=new InputReader(System.in); static OutputWriter out=new OutputWriter(System.out); static StringBuilder sb=new StringBuilder(); static long MOD = (long)(998244353); // Main Class Starts Here ...
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() 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.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.InputMismatchException; public class B { private static int n; private static int[] a; public static void main(String[] args) { 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...
import java.lang.*; import java.util.*; import java.io.*; public class Main { void solve(){ int t=ni(); while(t-->0) { int n = ni(); int a[] = new int[2 * n + 1]; for (int i = 1; i <= 2 * n; i++) a[i] = ni(); Arrays.sort(a, 1, 2*n + 1); 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...
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase 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...
for _ in range(int(input())): n=int(input()) lst=list(map(int,input().split())) lst.sort() 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.*; public class Main { static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { int n = Intege...
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 python from __future__ import division, print_function import math import os import sys from fractions import * from sys import * from decimal import * from io import BytesIO, IOBase from itertools import * from collections import * # sys.setrecursionlimit(10**5) M = 10 ** 9 + 7 # print(math.factorial(...
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()) n*=2 a=list(map(int, input().split())) a.sort() print(a[n//2]-a[n//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...
for _ in range(int(input())): w=int(input()) l=sorted(list(map(int,input().split()))) print(l[w]-l[w-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 <class T> inline void out(T t) { cout << t << "\n"; } template <class T, class... Ts> inline void out(T t, Ts... ts) { cout << t << " "; out(ts...); } template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return true; } return fa...
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(0,T): N=int(input()) a,b=map(int,input().split()) s=input() s=[int(x) for x in input().split()] for i in range(0,len(s)): a,b=map(int,input().split())""" T=int(input()) for _ in range(0,T): n=int(input()) s=[int(x) for x in input().split()] s.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...
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; public class AssignToClass { static void solve(BufferInput bi, BufferOutput bo) throws IOException { int N = bi.nextInt(); int arr[] = bi.nextIntArray(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; struct trp { int x, y, z; }; void fun() {} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[2 * n]; for (long long 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...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int n; cin >> n; vector<int> a; a.resize(2 * n); for (int i = 0; i < 2 * n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); cout << 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...
for _ in range(int(input())): n = int(input()) l = [*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...
t = int(input()) for i in range(t): n = int(input()) ni = list(map(int,input().split())) ni.sort() i1 = n-1 i2 = n print(ni[i2]-ni[i1])
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 os import path import sys # mod = int(1e9 + 7) # import re # can use multiple splits # from math import ceil, floor,gcd from collections import defaultdict , Counter # from bisect import bisect_left, bisect_right #popping from the end is less taxing,since you don't have to shift any elements maxx = float('inf') ...
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(j) for j 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...
import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; public class Codechef { static long fac[] = new long[1000001]; static void perm() { fac[0]=1; for (int x=1;x<=1000000;x++) fac[x]=fac[x-1]*x; } static long power(long x, long y, long 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...
/*package whatever //do not write package name here */ import java.io.*; import java.util.*; public class S { public static void main (String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t--!=0) { int n=in.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...
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x %= p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long po(long long base, long long powerRaised) { if (powerRaised != ...
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::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<long long> v(2 * n); for (int i = 0; i < 2 * n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); int b = (2 * n) / 2; 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...
q = int(input()) for _ in range(q): n = int(input()) s = list(map(int, input().split())) s.sort() print(s[n] - s[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()) ans = [] for _ in range(t): n = int(input()) arr = list(map(int,input().split())) arr.sort() ans.append( str(arr[n] - arr[n-1]) ) print("\n".join(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...
for _ in range(int(input())): me=int(input()) you=list(map(int,input().split())) you.sort() print(you[me]-you[me-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 = sorted(list(map(int, input().split()))) # print(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...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(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...
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.InputMismatchException; import java.util.*; import java.io.*; import java.ma...
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 for _ in range(int(input())): n=int(input()) arr=[int(k) for k in 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...
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(); int[] ar = 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 cb { 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(); int a[]=new int[2*n]; int j; for(j=0;j<2*n;j++) a[j]=sc.nextInt(); Arrays.sort(a); int d=a[n]-a[n-1]; System...
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 gcd(long long a, long long b) { if (a == 0) return b; else return gcd(b % a, a); } long long findGCD(vector<long long> arr, long long n) { long long result = arr[0]; for (long long i = 1; i < n; i++) result = gcd(arr[i], result); return 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...
def absolute_diff(n, arr): arr.sort() index = len(arr)//2 return abs(arr[index]-arr[index-1]) if __name__ == "__main__": t = int(input()) tests = [] for i in range(t): tests.append((int(input()), list(map(int, input().rstrip().split())))) for t in tests: print(absolute_...
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...
a = int(input()) for i in range(0,a): S1 = 0 S2 = 0 n = int(input()) arr = map(int, input().split()) arr = list(arr) arr.sort() print(arr[n] - arr[n - 1]) ''' for i in range(0,n*2,2): S1 = S1 + arr[i] S2 = S2 + arr[i+1] res = abs(S2 - S1)/n 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 main(): def med(a): if len(a) == 1: return a[0] return sorted(a)[len(a)//2] t = int(input()) for qweqerq in range(t): n = int(input()) a = list(map(int,input().split())) a.sort() b = a.pop(n) print(abs(b - med(a))) 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 java.util.*; public class Cp2 { public static void main(String dfgsdg[]){ Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-->0){ int n = in.nextInt(); int a[] = new int[2*n]; for(int i =0;i<2*n;i++){ a[i] = in.nex...
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 _0638AssigningtoClasses { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cases=sc.nextInt(); while(cases>0) { int n=sc.nextInt(); n=2*n; int[] arr = new int[n]; for(int i=0;i<n;i++) { arr[i]=sc...
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 javafx.util.Pair; import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main implements Runnable { boolean multiple = true; long MOD = 1000000007; @SuppressWarnings("Duplicates") void solve() throws Exception { int n = sc.nextInt(); Integer[] ar...
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.ArrayList; import java.io.*; import java.util.Collection; import java.util.Collections; import java.util.Scanner; public class S { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { 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...
t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input().split())) a.sort() a1=[] a2=[] for j in range(1,2*n,2): a1.append(a[j-1]) a2.append(a[j]) if n%2==1: x=(n+1)//2-1 s=abs(a1[x]-a2[x]) else: x=a1[0] a1.remove(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...
n1=int(input()) for x in range(n1): n2=int(input()) n3=input().split(" ") for y in range(2*n2): n3[y]=int(n3[y]) n3.sort() print(abs(n3[n2]-n3[n2-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 T in range(t): 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...
import java.io.*; import java.util.Arrays; import java.util.stream.Stream; public class CodeForcesMain { private void code() throws IOException { int times = readlineInt(); for (int t = 0; t < times; t++) { int n = readlineInt(); int[] a = readlineInts(); Arrays....
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 solve() { 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 - 1] - a[n]) << endl; return 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 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...
for t in range(int(input())): l=int(input()) a=list(map(int,input().split())) a.sort() cA = 0 A=[] cB = 0 B=[] for i in range(2*l): if cA > cB: cB+=a[i] B.append(a[i]) else: cA+=a[i] A.append(a[i]) if len(A)%2 == 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...
I=input for _ in[0]*int(I()):n=int(I());a=sorted(map(int,I().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...
t=int(input()) for i in range (t): n=int(input()) ans=0 c=0 x=input() a=x.split() for i in range(len(a)): a[i]=int(a[i]) a=sorted(a) x=int(len(a)/2) ans=a[x]-a[x-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 math t = int(input()) for x in range(t): n = int(input()) raw_arr = input() arr = raw_arr.split() arr = [int(i) for i in arr] arr = sorted(arr) 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...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() s = a[n] - a[n - 1] print(s)
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 jk in range(int(input())): q = int(input()) numArray = [int(x) for x in input().split()] numArray.sort() print(numArray[q]-numArray[q-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=list(map(int,input().split())) a.sort() n=2*n print(a[n//2]-a[n//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=input() while t: t-=1 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...
#include <bits/stdc++.h> using namespace std; void wldd() { long long n; cin >> n; long long a[2 * n]; for (long long i = 0; i < 2 * n; i++) cin >> a[i]; sort(a, a + 2 * n); cout << abs(a[n - 1] - a[n]) << "\n"; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; ...
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 def solve(): n = int(input()) al = list(map(int,input().split())) al.sort() k = n print(al[k]-al[k-1]) def main(): t = int(input()) for _ in range(t): solve() 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) { FastReader f = new FastReader(); int t = f.nextInt(); while (t-- > 0) { int n = f.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 sys input = sys.stdin.readline def main(): t = int(input()) for _ in range(t): N = int(input()) A = [int(x) for x in input().split()] A.sort() print(A[N] - A[N - 1]) 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...
# Problem B T = int(input()) for _ in range(T): n = int(input()) skills = sorted(list(map(int, input().split()))) median1 = skills[n-1] median2 = skills[n] diff = abs(median1 - median2) print(diff)
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 classass(): tests = int(input()) for i in range(tests): n = int(input()) arr = list(map(int,input().split())) arr.sort() print(abs(arr[n-1] - arr[n])) arr *= 0 classass()
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; n = n << 1; vector<int> values(n); for (auto& x : values) cin >> x; sort(values.begin(), values.end()); cout << values[n / 2] - values[n / 2 - 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...
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n; long long a[2 * n]; for (int i = 0; i < 2 * n; i++) cin >> a[i]; sort(a, a + 2 * n); int ans = a[n] - a[n - 1]; cout << ans << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t ...
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()) 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...
t=int(input()) while t: n=int(input()) a=list(map(int,input().split())) a.sort() print(a[n]-a[n-1]) 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 _ in range(t): n = int(input()) s = [int(x) for x in input().split()] s = sorted(s) print (abs(s[n]-s[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()) import math from queue import PriorityQueue for ti in range(t): n=int(input()) li = [int(i) for i in input().split(' ')] # li1 = [] # li2 = [] li.sort() t1 = t2 = n t1 = n-1 flg = 0 ans = 192608171919810 #ans = min(ans,abs(li2[t2]-li1[t1])) print(abs(li...
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() 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...
t=int(input()) while(t): t-=1 n=int(input()) a=list(map(int,input().split())) a.sort() ma1,ma2=-float('inf'),-float('inf') c,d=[],[] #print(a) if(n%2): for i in range(2*n): if(i%2==0): c.append(a[i]) else: d.append(a[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...
t = int(input()) while int(t)>0: n = int(input()) q = input() a = q.split() for i in range(0, n*2): a[i] = int(a[i]) a.sort() s = a[n]-a[n-1] print(s) 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.util.Collections; import java.io.InputStreamReader; import java.util.ArrayList; import java.io.InputSt...
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 N = 2e5 + 10; int a[N]; int32_t main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> 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...
import java.util.*; import java.lang.Math; import java.util.Arrays; import java.util.Scanner; import java.util.stream.IntStream; import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; pu...
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 javax.swing.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.*; public class simple1 implements Runnable { public void run() { InputReade...
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_cases = int(input()) for i in range(num_cases): num_elements = int(input())*2 array = [int(n) for n in input().split()] array.sort() print(array[num_elements//2] - array[(num_elements//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...
import java.io.*; import java.util.Arrays; public class QB_Jan { private static class Reader { final private int BUFFER_SIZE = 1 << 512; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; private Reader() { ...
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([int(i) for i in 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...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> arr(2 * n); for (auto &x : arr) cin >> x; sort(arr.begin(), arr.end()); int ans = 0; cout << arr[n] - arr[n - 1] << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--...
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...
# @author import sys class BAssigningToClasses: def solve(self): for _ in range(int(input())): n = int(input()) a = [int(_) for _ in input().split()] a.sort() # print(a) ans = float('inf') for i in range(2 * 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 final class AssignClass { 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(); int arr[]=new int[2*n]; for(int j=0;j<2*n;j++) arr[j]=sc.nextInt(); Arrays.par...
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()) 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...
t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] a.sort() n *= 2 if n == 2: print(abs(a[-1]-a[0])) else: print(a[n//2]-a[n//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...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 5; int mod7 = 1e9 + 7; int main() { int n, m; cin >> n; while (n--) { cin >> m; int arr[MAX] = {}; for (int i{0}; i < 2 * m; i++) cin >> arr[i]; sort(arr, arr + 2 * m); cout << abs(arr[m] - arr[m - 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...
t = int(input()) for i in range(t): p = int(input()) a = list(int(x) for x in input().split()) a.sort() print(a[p]-a[p-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 n; int a[200005]; int b[200005]; int c[200005]; void work() { cin >> n; n = n << 1; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); int ans = abs(a[n / 2] - a[n / 2 + 1]); cout << ans << "\n"; } int main() { int T; cin >> T; while (T-...
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: n = int(input()) a = list(map(int,input().split())) a.sort() print(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...
n = int(input()) for _ in range(n): t = int(input()) l = [int(x) for x in input().split()] a = l.count(0) l.sort() print(l[t]-l[t-1])