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... | number = int(input())
for _ in range(number):
x = int(input())
all_list = sorted([int(y) for y in input().split()])
print(abs(all_list[x] - all_list[x - 1]))
|
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t = int(input())
for _ in range(t) :
n = int(input())
l = list(map(int,input().split()))
l.sort()
a = l[n]
b = l[n-1]
print(a-b) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... |
import os
import sys
from collections import deque,defaultdict
import math
# Complete the rustMurdered function below.
#
class Pair:
def __init__(self,x,y):
self.x = x
self.y = y
# Write your code here.
#
if __name__ == '__main__':
#fptr = open(os.environ['OUTPUT_PATH'], 'w')
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... | from math import *
def median(arr):
sorted_arr = sorted(arr)
return sorted_arr[len(sorted_arr) // 2]
def func(arr):
n = len(arr) // 2
arr.sort()
a, b = arr[n - 1], arr[n]
return b - a
t = int(input())
arr_levels = []
for _ in range(t):
halved = int(input())
s = input()
s = s.split()
tmp_arr = []
for el... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | y=input
for i in[0]*int(y()):n=int(y());l=sorted(map(int,input().split()));print(l[n]-l[n-1]) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/*
Прокрастинирую
*/
public class Main {
static FastReader in;
static PrintWriter out;
static Random rand = new Random();
static final int INF = (int) (1e9 + 10);
static final int MOD = (int) (1e9 + ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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())*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... | cases = int(input())
for i in range(cases):
line1 = int(input())
line2 = input().split(' ')
arr = []
for a in line2:
arr.append(int(a))
if (len(arr)== 2):
print(abs(arr[1]-arr[0]))
continue
arr.sort()
midleft = int(len(arr)/2)-1
midright = int(len(arr)/2)
med1... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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=input().split()
for i in range(2*n):
a[i]=int(a[i])
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... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Question1300B {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while (t--!=0){
int n=sc.nextInt();
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, i, j, k, m, n;
t = 1;
cin >> t;
while (t--) {
cin >> n;
vector<long long int> ar(2 * n, 0), a1(n, 0), a2(n, 0);
for (long long int i = 0; i < 2 * n; i++) {
cin >> ar[i];
}
sort((ar).begin(), (ar).end());
lo... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | from sys import stdin
input=stdin.readline
#import bisect
#i = bisect.bisect_left(a, k)
#list=input().split(maxsplit=1)
for xoxo in range(1):
a=[]
for _ in range (int(input())):
n=int(input())
#ans=[]
#n,k=map(int, input().split())
ans=0
a=list(map(int, input().split()))
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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=sorted(list(map(int,input().split())))
i=len(a)//2
print(abs(a[i]-a[i-1])) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
public class AssigningToClasses {
public static void main(String[]args) {
Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int t=s.nextInt();
whi... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 = 3e5 + 20;
int a[N];
void solve() {
int n;
cin >> n;
for (int i = 1; i <= 2 * n; i++) {
cin >> a[i];
}
sort(a + 1, a + 2 * n + 1);
cout << a[n + 1] - a[n] << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
|
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | test_cases = int(input())
for _ in range(test_cases):
array_len = int(input())
array = list(map(int, input().split()))
array.sort()
print(array[array_len] - array[array_len - 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())
data=[int(x) for x in input().split()]
data.sort()
a=data[n-1]-data[n]
a=abs(a)
print(a) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | #include <bits/stdc++.h>
using namespace std;
map<long long, list<long long>> m;
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
n *= 2;
long long arr[n];
for (long long i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
cout << arr[n / 2] - 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.io.IOException;
import java.io.InputStream;
import java.util.*;
public class codechef {
public static void main(String args[]) throws Exception {
FastReader in = new FastReader(System.in);
int testcases=in.nextInt(),i;
StringBuilder sb = new StringBuilder();
while(testca... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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()
m = 2*n
x = abs(arr[n-1]-arr[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... | t=int(input())
for i in range(t):
n=int(input())
l=list(map(int,input().split()))
l.sort()
print(abs(l[n-1]-l[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 collections, heapq
def main():
T = int(input().strip())
for _ in range(T):
n = int(input().strip())
a = [int(x) for x in input().strip().split(" ")]
a.sort()
print(a[n]-a[n-1])
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.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class p1290A {
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];
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | from sys import stdin
def inp():
return (ss.rstrip() for ss in stdin).__next__()
def itg():
return int(inp())
def mpint():
return map(int, inp().split())
for case in range(itg()):
n = itg()
arr = list(mpint())
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())
for _ in range(t):
n = int(input())
m = list(map(int, input().split()))
m = sorted(m)
print(m[n] - m[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>
const int mod = 1e9 + 7;
const int mx = 1e5 + 5;
using namespace std;
int solve() {
int n;
cin >> n;
n *= 2;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
cout << arr[n / 2] - arr[n / 2 - 1] << endl;
return 0;
}
int main() {
ios_base::sync_with_std... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t=int(input())
for j in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
n=2*n
print(abs(a[n//2-1]-a[n//2])) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t = int(input())
for _ in range(t):
n = int(input())
a = sorted(list(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... | def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 #Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first half
mergeSort(R) # Sorting the second half
i = j = k = 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;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
const long double eps = 1e-10;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &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... | t=int(input())
for i in range(t):
n=int(input())
a=[int(i) for i in input().split()]
m=9999999999999999
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.Scanner;
import java.util.Arrays;
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[] 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... | #include <bits/stdc++.h>
using namespace std;
int t, n;
int a[200010];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> t;
while (t--) {
cin >> n;
for (int 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
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++) {
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... | #include <bits/stdc++.h>
using namespace std;
int T;
int n;
int a[200005];
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]);
sort(a + 1, a + n + n + 1);
printf("%d\n", a[n + 1] - a[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... | import sys
input=lambda:sys.stdin.readline().rstrip()
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 a[200005];
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= n * 2; i++) {
cin >> a[i];
}
sort(a, a + n * 2 + 1);
cout << abs(a[n + 1] - a[n]) << endl;
}
}
|
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
a.sort()
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())
class1=[]
class2=[]
inputs=list(map(int,input().split()))
inputs.sort()
if n%2==1:
for j in range(0,2*n,2):
class1.append(inputs[j])
class2.append(inputs[j+1])
print(class2[int((n/2))]-class1[int((n/2))])
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
public class CodeForces {
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.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.*;
import java.io.*;
public class Solution {
public static void main (String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter out=new PrintWriter(System.out);
String[] temp=br.readLine().trim().split(" ");
int numTestCases=... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve() {
for(int T = ni(); T > 0; T--) {
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... | // package Contest1300;
import java.util.*;
import java.lang.*;
import java.io.*;
public class B {
private static FastReader fr;
private static OutputStream out;
private static int mod = (int)(1e9+7);
private void solve() {
int t = fr.nextInt();
while(t-- > 0) {
int n = fr.nextInt();
int arr[] = fr.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... | n=int(input())
l=[]
for i in range(n):
a=int(input())
b=input().split()
for j in range(2*a):
b[j]=int(b[j])
b=sorted(b)
l.append(b)
for i in range(n):
print (abs(l[i][int(len(l[i])/2-1)]-l[i][int(len(l[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... | from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math 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;
void doit() {
int n;
cin >> n;
int a[n + n];
for (int i = 0; i < 2 * n; i++) {
cin >> a[i];
}
sort(a, a + 2 * n);
cout << a[n] - a[n - 1] << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 unsigned int M = 1000000007;
void solve() {
int n;
cin >> n;
;
int arr[2 * n];
for (int i = 0; i < 2 * n; i++) cin >> arr[i];
sort(arr, arr + 2 * n);
cout << arr[n] - arr[n - 1] << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
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... | import java.util.*;
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();
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 td in range(t):
n = int(input())
a = list(map(int,input().split()))
a.sort()
d = abs(a[n] - a[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.*;
public class Solver {
static Scanner in = new Scanner(System.in);
public static void main(String[] args) {
int T = in.nextInt();
while (T-- > 0) {
int n = in.nextInt();
int[] z = new int[n * 2];
for (int i = 0; i < z.length; i++) {
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | #include <bits/stdc++.h>
using namespace std;
void init() {
if (fopen("cf.inp", "r")) {
freopen("cf.inp", "r", stdin);
freopen("cf.out", "w", stdout);
}
}
long long t, n, x, y, k, a[1000000];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
init();
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())
cases = []
for _ in range(t):
n = int(input())
a = [int(i) for i in input().split()]
cases.append(a)
for c in cases:
c.sort()
l = len(c)
print(c[l // 2] - c[l // 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;
int main() {
int t;
cin >> t;
while (t != 0) {
vector<int> v;
int n, i;
cin >> n;
for (i = 0; i < 2 * n; i++) {
int x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
int m1, m2, d;
m1 = (v.size() - 1) / 2;
m... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | //package round618;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamRe... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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()
for i in range(t):
n=input()
l=list(map(int,raw_input().split()))
l.sort()
if n%2<>0:
print abs(l[n]-l[n-1])
else:
print min(abs(l[n-2]-l[n+1]),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... | import math
t=int(input())
for i in range(0,t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=a[n]-a[n-1]
c=int(math.fabs(c))
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... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T>& operator--(vector<T>& v) {
for (auto& i : v) --i;
return v;
}
template <typename T>
vector<T>& operator++(vector<T>& v) {
for (auto& i : v) ++i;
return v;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
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... | 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... | def solve():
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(A[N] - A[N-1])
T = int(input())
for i in range(0, T):
solve() |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | def solve(A, N):
assert len(A) == 2 * N
A.sort()
best = float("inf")
for i, x in enumerate(A):
lo = i + 1
hi = 2 * N - i - 1
if lo > hi:
break
mid = (lo + hi) // 2
# print(A[i], A[: i + 1] + A[2 * N - i :], A[i + 1 : 2 * N - i], A[mid])
best = ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import os
import sys
from io import BytesIO, IOBase
def main():
t = int(input())
def solution(arr, n):
arr.sort()
print(arr[n] - arr[n - 1])
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
solution(arr, n)
# region fastio
BUFSIZE = 8... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 MOD = (int)1e9 + 7;
int t;
void solve() {
long long n;
cin >> n;
vector<long long> a(n * 2);
for (auto &i : a) cin >> i;
sort(a.begin(), a.end());
cout << a[n] - a[n - 1] << endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* https://codeforces.com/contest/1300/problem/B
*
* @author Maksim
*
*/
public class TaskB {
public... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 -*-
t = int(input())
for i in range(t):
n = int(input())
A = [int(i) for i in input().split()]
A.sort()
r = abs(A[n-1] - A[n])
print(r) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t=int(input())
for _ in range(t):
n=int(input())
l=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... | if __name__ == "__main__":
t=int(input())
for i in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n]-a[n-1])
|
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | import java.util.*;
public class Solution
{
private static Scanner s;
public static void main(String[] args)
{
s=new Scanner(System.in);
int t=s.nextInt();
for(int i1=0;i1<t;i1++)
{
int n=s.nextInt();
s.nextLine();
String[] val=s.nextLine()... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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;
scanf("%d", &n);
vector<int> a(2 * n);
for (int i = 0; i < 2 * n; i++) scanf("%d", &a[i]);
sort(a.begin(), a.end());
printf("%d\n", abs(a[n] - a[n - 1]));
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
solve();
}
return ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 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;
}
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... | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I(): return int(input())
def MI(): return map(int, input().split())
def ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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(list(map(int, 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... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
A, B = [], []
for i in range(0, len(a), 2):
A.append(a[i])
B.append(a[i+1])
if len(A)%2 == 0:
A.append(B.pop())
print(abs(A[len(A)//2]-B[len(B)//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;
int main() {
long long t;
cin >> t;
while (t--) {
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 << 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 i in range(int(input())):
n=int(input())
ls=[int(a) for a in input().split()]
ls.sort()
print(abs(ls[n]-ls[n-1])) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t = int(input())
for i in range(t):
n = int(input())
ai = list(map(int,input().split()))
ai.sort()
print(ai[n]- ai[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 t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long z = 2 * n;
long long a[z + 1];
a[0] = 0;
for (long long i = 1; i <= z; i++) cin >> 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... | /* package codechef; // don't place package name! */
import java.util.Scanner;
import java.util.Arrays;
/* 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
{
try {
Scanner sc = new Scanner(System.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... | 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();
outer:
while (t-- >= 1) {
int n = sc.nextInt();
int a[] = new int[2 * n];
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... | def func(arr: list) -> int:
arr.sort()
n = len(arr)
return arr[n//2] - arr[n//2-1]
def start():
t = int(input())
for i in range(t):
n = int(input())
arr = []
arr = list(map(int, input().split(" ")))
print(func(arr))
if __name__ == '__main__':
start() |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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 os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def main():
t = int(input())
for _ in range(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() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t, n;
cin >> t;
while (t--) {
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));
long long 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=2*int(input())
l=list(map(int,input().split()))
l.sort()
ans = max(l)-min(l)
# print(ans)
# print(l)
# print(l[n//2])
# print(l[n//2-1])
for j in range(n//2):
ans=min(abs(l[j]-l[n//2]),ans)
for j in range(n//2,n):
ans=min(abs(l[j]-l[n//2-1]),ans)
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 java.util.Arrays;
import java.util.Scanner;
public class AssigningToClasses {
/**
* @param args
*/
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... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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
from collections import defaultdict,Counter
# input=sys.stdin.readline
# def print(x):
# sys.stdout.write(str(x)+"\n")
# sys.stdout=open("CP1/output.txt",'w')
# sys.stdin=open("CP1/input.txt",'r')
# m=pow(10,9)+7
t=int(input())
for i in range(t):
n=int(input())
a=list(map(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... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Contest {
public static long gcd(long n1, long n2)
{
if (n2 != 0)
return gcd(n2, n1 % n2);
else... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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())
x=list(map(int,input().split()))
x.sort()
print(abs(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... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t = 1, i, j;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a[2 * n];
for (i = 0; i < 2 * n; i++) cin >> a[i];
sort(a, a + (2 * n));
long long ans = a[n] - a[n - 1];
cout << ans << 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... | # 1 2 50 100 200 201
t = int(input())
for i in range(t):
n = int(input())
l = list(map(int, input().split()))
l.sort()
print(l[n] - l[n - 1])
|
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | def zip_sorted(a,b):
# sorted by a
a,b = zip(*sorted(zip(a,b)))
# sorted by b
sorted(zip(a, b), key=lambda x: x[1])
return a,b
def number_to_list(a):
b = []
while a>=1:
c = a%10
a = int(a/10)
b.append(c)
return list(reversed(b))
def str_list_to_int_list(a):
a = list(map(int,a))
return a
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | t=int(input())
for i in range(t):
n=int(input())
l=sorted(list(map(int,input().split(" "))))
print(l[n]-l[n-1]) |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | #include <bits/stdc++.h>
using namespace std;
long long int a[200020];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 0, n = 0;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= 2 * n; ++i) cin >> a[i];
if (n == 1)
cout << abs(a[2] - a[1]);
else {
sort(a... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
scanf("%lld ", &t);
while (t--) {
long long n;
cin >> n;
long long r = 2 * n;
vector<long long> a;
vector<long long> b;
vector<long long> c1;
while (r--) {
long long c;
cin >> c;
c1.push_back(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 tests 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 java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
public class Assigning {
public static void main(String[] args) throws IOException{
BufferedReader b1 = new Buff... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the 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.util.Arrays;
import java.util.*;
public class d6182
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
int t,i;
t=sc.nextInt();
double st=System.nanoTime();
while(t>0)
{
t--;
int n=sc.nextInt();
Integer a[]=new Integer[2*n];
... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | #include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N];
int main() {
register int t;
scanf("%d", &t);
while (t--) {
register int n;
scanf("%d", &n);
register int p = (n << 1);
for (register int i = 1; i <= p; ++i) {
scanf("%d", &a[i]);
}
sort(a + 1, 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... | t=int(input())
for _ in range(0,t):
n=int(input())
a=list(map(int,input().split()))
if len(a)==2:
print(abs(a[0]-a[1]))
else:
a.sort()
print(abs(a[len(a)//2-1]-a[len(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... | t = int(input())
for i in range(t):
n = int(input())
c = list(map(int, input().split()))
c.sort()
print(c[n]-c[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 binarySearch(arr,x):
l=0
r=len(arr)-1
while l <= r:
mid = (l + r)//2;
if arr[mid] == x:
return mid
elif arr[mid] < x:
l = mid + 1
else:
r = mid - 1
return -1
def js(arr,x):
l=0
r=len(arr)-1
ans=-1
while(l<=r):
m=(l+r)//2
if(arr[m]<=x):
ans=m
l=m+1
else:
r=m-1
return ... |
Problem: Reminder: the [median](https://en.wikipedia.org/wiki/Median) of the array [a_1, a_2, ..., a_{2k+1}] of odd number of elements is defined as follows: let [b_1, b_2, ..., b_{2k+1}] be the elements of the array in the sorted order. Then median of this array is equal to b_{k+1}.
There are 2n students, the i-th st... | ''' ===============================
-- @uthor : Kaleab Asfaw
-- Handle : kaleabasfaw2010
-- Bio : High-School Student
==============================='''
# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file): self._fd = file.fil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.