message
stringlengths
2
433k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
113
108k
cluster
float64
12
12
__index_level_0__
int64
226
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers a and b of length n. It turned out that arra...
instruction
0
87,731
12
175,462
No
output
1
87,731
12
175,463
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,748
12
175,496
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` from sys import stdin, setrecursionlimit, stdout #setrecursionlimit(1000000) from collections import deque from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin from heapq import heapify, heappop, heappush, heappushpop, h...
output
1
87,748
12
175,497
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,749
12
175,498
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` for t in range(int(input())): n = int(input()) lst= list(map(int, input().split())) r = s = rs = 0 x=n//2 for i in range(x): s =s+ (lst[2 * i + 1] - lst[2 * i]) rs = rs+ lst[2 * i] s = max(s, 0) ...
output
1
87,749
12
175,499
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,750
12
175,500
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` import sys t=int(sys.stdin.readline()) for i in range (t): num=0 parr=0 imparrr=0 n=int(sys.stdin.readline()) a=list(map(int,input().split())) suma=0 for i in range(len(a)): if i%2==0: suma+=a[i] ...
output
1
87,750
12
175,501
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,751
12
175,502
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` def main(): t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) print(f(n, a)) def f(n, a): odd_sum = 0 for i in range(0, n, 2): odd_sum += a[i] prefix = 0 mi...
output
1
87,751
12
175,503
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,752
12
175,504
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` import sys import random from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): retu...
output
1
87,752
12
175,505
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,753
12
175,506
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` import sys input = sys.stdin.buffer.readline Q = int(input()) Query = [] for _ in range(Q): N = int(input()) A = list(map(int, input().split())) Query.append((N, A)) def solve(A, ans): nowmin = 0 w = 0 for p1 in A: ...
output
1
87,753
12
175,507
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,754
12
175,508
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) tot = 0 dif1 = 0 extra = 0 for i in range(0,n,2): tot+=a[i] for i in range(0,n-1,2): dif1-=a[i] dif1+=a[i+1] ...
output
1
87,754
12
175,509
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall t...
instruction
0
87,755
12
175,510
Tags: divide and conquer, dp, greedy, implementation Correct Solution: ``` def maxSubArraySum(a,size): max_so_far =a[0] curr_max = a[0] for i in range(1,size): curr_max = max(a[i], curr_max + a[i]) max_so_far = max(max_so_far,curr_max,0) return max(max_so_f...
output
1
87,755
12
175,511
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,756
12
175,512
Yes
output
1
87,756
12
175,513
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,757
12
175,514
Yes
output
1
87,757
12
175,515
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,758
12
175,516
Yes
output
1
87,758
12
175,517
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,759
12
175,518
Yes
output
1
87,759
12
175,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,760
12
175,520
No
output
1
87,760
12
175,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,761
12
175,522
No
output
1
87,761
12
175,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,762
12
175,524
No
output
1
87,762
12
175,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,763
12
175,526
No
output
1
87,763
12
175,527
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray ...
instruction
0
87,764
12
175,528
No
output
1
87,764
12
175,529
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,785
12
175,570
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` n = int(input()) a = [int(x) for x in input().split()] ans = set([]) for i in range(n): x = 1 while x <= a[i]: x *= 2 j = i+1 sum = 0 while j < n-1 and sum < x: ...
output
1
87,785
12
175,571
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,786
12
175,572
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` import sys try:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w') except:pass ii1=lambda:int(sys.stdin.readline().strip()) # for interger is1=lambda:sys.stdin.readline().strip() # for str...
output
1
87,786
12
175,573
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,787
12
175,574
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` def solve(a): seen = set() for i in range(len(a)): c = 0 for j in range(i+2,len(a)): c += a[j-1] if a[i]^a[j] == c: seen.add((i,j)) ...
output
1
87,787
12
175,575
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,788
12
175,576
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) def calc(a): ans = 0 for i in range(2, len(a)): sum = 0 for j in reversed(range(0, i-1)): sum += a[j+1] ans += a[i] > a[j] and a[i]...
output
1
87,788
12
175,577
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,789
12
175,578
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` import itertools, math n = int(input()) A = list(map(int, input().split())) acc = [0] + list(itertools.accumulate(A)) ans = 0 seen = set() for i in range(n - 2): a = int(math.log2(A[i])) f...
output
1
87,789
12
175,579
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,790
12
175,580
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` from bisect import * from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from funct...
output
1
87,790
12
175,581
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,791
12
175,582
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` from sys import * input = stdin.readline def solve(n, a, t): ans = 0 for i in range(n): sum = 0 high1 = a[i].bit_length()-1 for j in range(i+1, n-1): high2 = a[j+1].bit_length()-1 s...
output
1
87,791
12
175,583
Provide tags and a correct Python 3 solution for this coding contest problem. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: * l+1 ≤ r-1, i. e. th...
instruction
0
87,792
12
175,584
Tags: binary search, bitmasks, brute force, constructive algorithms, divide and conquer, two pointers Correct Solution: ``` def solve(a): seen = set() for i in range(len(a)): c = 0 for j in range(i+2,len(a)): c += a[j-1] if a[i]^a[j] == c: seen.add((i,j)) ...
output
1
87,792
12
175,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,793
12
175,586
Yes
output
1
87,793
12
175,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,794
12
175,588
Yes
output
1
87,794
12
175,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,795
12
175,590
Yes
output
1
87,795
12
175,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,796
12
175,592
No
output
1
87,796
12
175,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,797
12
175,594
No
output
1
87,797
12
175,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,798
12
175,596
No
output
1
87,798
12
175,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yurii is sure he can do everything. Can he solve this task, though? He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simu...
instruction
0
87,799
12
175,598
No
output
1
87,799
12
175,599
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,800
12
175,600
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` import sys from bisect import bisect_left input = sys.stdin.buffer.readline T = int(input()) for _ in range(T): n, b = int(input()), list(map(int, input().split())) setb = set(b) rb = [ u for u in range(1, 2*n+1) if no...
output
1
87,800
12
175,601
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,801
12
175,602
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` t=int(input()) for _ in range(t): n=int(input()) b=list(map(int,input().split())) s=set(b) arr=[1]*(2*n) pos=0 mini=0 for i in range(n): pos=max(pos,b[i]) temp=pos for j in range(pos,2*n): if(((j+1) not in s) and ar...
output
1
87,801
12
175,603
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,802
12
175,604
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` import os,io input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline INF=10**9+1 t=int(input()) for _ in range(t): n=int(input()) b=list(map(int,input().split())) maxofmins=0 minofmaxs=0 maxofmaxs=0 minofmins=0 poi...
output
1
87,802
12
175,605
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,803
12
175,606
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` t = int(input()) for _ in range(t): n = int(input()) b = list(map(int, input().split())) max_force = 0 min_force = 0 legacy = 0 possibility = 0 for i in b: jump = i - legacy - 1 possibili...
output
1
87,803
12
175,607
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,804
12
175,608
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` for _ in range(int(input())): n = int(input()) b = list(map(int, input().split())) used = [0] * (2*n+1) for x in b: used[x] = 1 a = [x for x in range(1, 2*n+1) if used[x]==0] max_ = 0 ...
output
1
87,804
12
175,609
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,805
12
175,610
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` tests = int(input()) for t in range(tests): n = int(input()) ls = list(map(int, input().split())) if min(ls) == (n+1) or max(ls) == (n): print(1) else: #right to left mini = 0 curr = ...
output
1
87,805
12
175,611
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,806
12
175,612
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` #! /usr/bin/env python3 import sys t = int(sys.stdin.readline()) for ti in range(t): n = int(sys.stdin.readline()) b = [int(a) for a in sys.stdin.readline().split()] max_min = -1 min_max = n prev = 0 E = ...
output
1
87,806
12
175,613
Provide tags and a correct Python 3 solution for this coding contest problem. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obta...
instruction
0
87,807
12
175,614
Tags: binary search, constructive algorithms, greedy, two pointers Correct Solution: ``` for _ in range(int(input())): n = int(input()) b = [int(x) for x in input().split()] j, count = 0, 0 bad_left, bad_right = 0, 0 for i in range(1, 2*n+1): if j < n and b[j] == i: j += 1 ...
output
1
87,807
12
175,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,808
12
175,616
Yes
output
1
87,808
12
175,617
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,809
12
175,618
Yes
output
1
87,809
12
175,619
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,810
12
175,620
Yes
output
1
87,810
12
175,621
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,811
12
175,622
Yes
output
1
87,811
12
175,623
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,812
12
175,624
No
output
1
87,812
12
175,625
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,813
12
175,626
No
output
1
87,813
12
175,627
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,814
12
175,628
No
output
1
87,814
12
175,629
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, y...
instruction
0
87,815
12
175,630
No
output
1
87,815
12
175,631
Provide tags and a correct Python 3 solution for this coding contest problem. A median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array (2, 6, 1, 2, 3) is ...
instruction
0
87,849
12
175,698
Tags: greedy, math, sortings Correct Solution: ``` def median(n,m,li): count = 0 li.sort() while True: if li[(n+1)//2 -1]== m: return count li.append(m) li.sort() n+=1 count+=1 n,m = input().split() li = [int(x) for x in input().split()] print(median(int(n),int(m),li)) ```
output
1
87,849
12
175,699