description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: perm1 = sorted(list(s1)) perm2 = sorted(list(s2)) zipped = zip(perm1, perm2) forward = True backward = True for x, y in zipped: if ord(x) > ord(y): forward = False ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER RETURN V...
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: x = "abcdefghijklmnopqrstuvwxyz" d = defaultdict(int) for i in range(len(x)): d[x[i]] = i + 1 a1 = [] a2 = [] for i in range(len(s1)): a1.append(d[s1[i]]) a2.appe...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL V...
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: c1 = Counter(s1) c2 = Counter(s2) s = set() diff = 0 for i in range(26): c = chr(ord("a") + i) diff += c1[c] - c2[c] if diff: s.add(diff > 0) retu...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR VAR BIN_OP VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER VAR
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: n = len(s1) s1 = sorted(s1) s2 = sorted(s2) s1_tally = 0 s2_tally = 0 for i in range(n): if s1[i] >= s2[i]: s1_tally += 1 if s2[i] >= s1[i]: s...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR VAR VAR VAR
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: def ifbreaks(a, b): a = sorted(a) b = sorted(b) for i in range(len(a)): if a[i] < b[i]: return False return True return ifbreaks(s1, s2) or ifbr...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa (in other words s2 can break s1). A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.   Example 1: Input: s1 = "ab...
class Solution: def checkIfCanBreak(self, s1: str, s2: str) -> bool: ar1 = [(0) for i in range(len(s1))] ar2 = [(0) for i in range(len(s2))] for i in range(len(s1)): ar1[i] = ord(s1[i]) ar2[i] = ord(s2[i]) ar1.sort() ar2.sort() flag1 = False ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMB...
You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an independent set if no two vertices are connected with an edge. Input The first line...
from sys import stdin, stdout T = int(stdin.readline()) ver = set() for _ in range(T): ver.clear() n, m = map(int, stdin.readline().split()) n *= 3 edge = [] for __ in range(m): u, v = map(int, stdin.readline().split()) if u not in ver and v not in ver: edge.append(__ + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
n, x = [int(x) for x in input().split()] l_ind = [[] for i in range(200000)] r_ind = [[] for i in range(200000)] for i in range(n): l, r, c = [int(x) for x in input().split()] if r - l + 1 <= x: l_ind[l - 1].append((l, r, c)) r_ind[r - 1].append((l, r, c)) ans = None bestCost = [None for i in ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR E...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
n, x = list(map(int, input().split())) V = [] for i in range(x + 1): V.append([]) for i in range(n): l, r, c = list(map(int, input().split())) if r - l + 1 <= x: V[r - l + 1].append([l, r, c]) for i in range(x + 1): V[i] = sorted(V[i]) ans = int(3000000000.0 + 7) for i in range(x + 1): mn = ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
import sys def main(): n, x = map(int, sys.stdin.readline().split()) al = [] starts = [] finishes = [] y = [(-1) for i in range(200002)] for i in range(n): a, b, c = map(int, sys.stdin.readline().split()) al.append((a, b, c)) starts.append((a, i)) finishes.appen...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_C...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
Q = map E = input B = range W = enumerate o = len P = min q = print def U(): return Q(int, E().split()) n, x = U() s = [[] for i in B(x - 1)] for d in B(n): l, r, c = U() if r - l < x - 1: s[r - l] += [[l, c]] for t in s: t.sort(key=lambda q: q[0]) m = 3000000000.0 for d, t in W(s): D = ...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR IF BIN_OP VAR VAR...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
from sys import stdin, stdout n, x = map(int, stdin.readline().split()) length = [[] for i in range(x + 1)] mins = [[] for i in range(x + 1)] challengers = [] for i in range(n): l, r, v = map(int, stdin.readline().split()) if r - l < x: length[r - l + 1].append((l, v)) for i in range(1, x + 1): if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP V...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
n, x = map(int, input().split()) arr = list(tuple(map(int, input().split())) for _ in range(n)) arr_first = arr[:] arr_second = arr[:] arr_first.sort(key=lambda i: i[0]) arr_second.sort(key=lambda i: i[1]) d, idx, res = {}, 0, int(10**18) for l, r, c in arr_second: while idx < n and r >= arr_first[idx][0]: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR DICT NUMBER FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR ...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
def main(): n, x = map(int, input().split()) vouchers = [False] * x for _ in range(n): lo, hi, cost = map(int, input().split()) w = hi - lo if w < x: l = vouchers[w] if l: l.append((lo, cost)) else: vouchers[w] = [(l...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR ASSIGN VAR VAR ...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
import sys input = sys.stdin.readline n, x = map(int, input().split()) lrc = [tuple(map(int, input().split())) for _ in range(n)] lrc.sort(key=lambda k: k[0]) lrc2 = lrc[:] lrc.sort(key=lambda k: k[1]) d = {} idx = 0 ans = 10**18 for l, r, c in lrc: while idx < n and r >= lrc2[idx][0]: k = x - (lrc2[idx][1...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
import sys input = sys.stdin.readline n, x = map(int, input().split()) vo = [list(map(int, input().split())) for i in range(n)] d = [[] for i in range(x + 1)] for l, r, c in vo: if r - l + 1 <= x: d[r - l + 1].append([l, c]) mins = [[] for i in range(x + 1)] for i in range(1, x + 1): if len(d[i]) == 0:...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUM...
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly x days. You...
n, x = map(int, input().split()) INF = float("inf") bestScore = [INF] * x q = [] for i in range(n): l, r, c = map(int, input().split()) q.append((l, -1, r, c)) q.append((r, 1, l, c)) q = sorted(q) ans = INF for i in range(len(q)): type = q[i][1] if type == -1: curLen = q[i][2] - q[i][0] + 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l.sort() m = l[:n] l = l[n:] print(l[n // 2]) for i in range(n): print(m[i], l[i], end=" ") print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR STRIN...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def solve(arr): lst = sorted(arr) n = len(arr) // 2 b = [] final = [] for i in range(n): b.append(max(lst[i], lst[i + n])) final.append(lst[i]) final.append(lst[i + n]) print(b[len(b) // 2]) print(" ".join(map(str, final))) t = int(input()) while t: n = int(inpu...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER E...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a = sorted(a, reverse=True) x = a[(n - 1) // 2] a = sorted(a) print(x) for i in range(n): print(a[i], a[n + i], end=" ") print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXP...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) for _ in range(t): n = int(input()) arr = [int(i) for i in input().split()] arr.sort() print(arr[(3 * n - 1) // 2]) for i in range(n): print(arr[i], arr[n + i], end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
T = int(input()) for _ in range(0, T): N = int(input()) a = list(map(int, input().split(" "))) a = sorted(a) print(a[(3 * N + 1) // 2 - 1]) print(*[y for x in zip(a[0:N], a[N : 2 * N]) for y in x if y is not None])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() median = 0 if n % 2 == 0: median = a[n + (n // 2 - 1)] else: median = a[n + n // 2] ans = [] for i in range(n): ans.append(a[i]) ans.append(a[-i - 1]) print(med...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMB...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): N = int(input()) A = list(map(int, input().split())) A.sort() B = A[N:] C = A[:N] X = [] p = B[N // 2] print(p) for i, j in zip(B, C): X.append(i) X.append(j) print(*X)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR E...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def quicksort(myList, start, end): if start < end: pivot = partition(myList, start, end) quicksort(myList, start, pivot - 1) quicksort(myList, pivot + 1, end) return myList def partition(myList, start, end): pivot = myList[start] left = start + 1 right = end done = Fals...
FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR WHILE VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
T = int(input()) for t in range(T): N = int(input()) A = list(map(int, input().split())) A.sort() print(A[-((N + 1) // 2)]) B = [] N *= 2 for i in range(N // 2): B.extend([str(A[i]), str(A[i + N // 2])]) print(" ".join(B))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUN...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
from sys import stdin def permute_max_median(A): A.sort() median = A[len(A) // 2 + len(A) // 4] for i in range(len(A) // 2): A[i * 2 + 1], A[len(A) // 2 + i] = A[len(A) // 2 + i], A[i * 2 + 1] return median def main(): from sys import stdin T = int(stdin.readline()) for t in ran...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR BIN_OP BIN_...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) for _ in range(t): n = int(input()) arr = sorted(list(map(int, input().split()))) a = arr[n : 2 * n] print(a[n // 2]) for i in range(n): print(arr[i], arr[n + i], end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) a = [int(i) for i in input().split()] a.sort() b = [] for i in range(n): b.append(max(a[i], a[len(a) - 1 - i])) if n % 2 == 1: print(b[(n - 1) // 2]) else: print(max(b[len(b) // 2 - 1], b[len(b) // 2])) for i in range...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMB...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): N = int(input()) A = list(map(int, input().split())) A.sort() up = A[N:] down = A[:N] print(up[N >> 1]) A = [] for x, y in zip(down, up): A.append(x) A.append(y) print(" ".join(map(str, A)))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for tc in range(int(input())): n = int(input()) l = list(map(int, input().split())) l.sort() a = l[:n] b = l[n : 2 * n] m = [] for i in range(n): m.append(a[i]) m.append(b[n - 1 - i]) print(l[3 * n // 2]) for i in m: print(i, end=" ") print("\n")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t: t = t - 1 n = int(input()) b = [] a = list(map(int, input().split())) a.sort() a1 = [-1] * (2 * n) k1 = 2 * n - 1 k2 = 0 for i in range(0, len(a)): if i % 2 == 0: a1[i] = a[k1] k1 -= 1 else: a1[i] = a[k2] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
tests = int(input()) for i in range(tests): length = int(input()) arr = list(map(int, input().split())) arr.sort() ans = [] for j in range(length): ans.append(arr[j]) ans.append(arr[-j - 1]) median_pos = length + length // 2 print(arr[median_pos]) print(*ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): N = int(input()) st = input().split() A = [] for x in st: A.append(int(x)) A.sort() p = N + N // 2 M = A[p] st = "" for k in range(N): st += str(A[k]) + " " + str(A[k + N]) + " " print(M) print(st)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR BIN_O...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
cases = int(input()) j = 0 while j < cases: j += 1 n = int(input()) mid = int((n - 1) / 2) a_raw = input().split() a = [int(x) for x in a_raw] a.sort() b = a[1::2] for i in range(mid): a[2 * i], a[2 * (n - i - 1)] = a[2 * (n - i - 1)], a[2 * i] b[i] = max(a[2 * i], b[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) a.sort() print(a[2 * n - 1 - (n - 1) // 2]) B = [] for i in range(n): B.append(str(a[i])) B.append(str(a[i + n])) print(" ".join(B))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t > 0: n = int(input()) a = list(map(int, input().split())) a.sort() b = a[: len(a) // 2] c = a[len(a) // 2 :] p = [0] * len(a) j = 0 k = 0 for i in range(len(p)): if i % 2 == 0: p[i] = b[j] j += 1 else: p[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for T in range(int(input())): N = int(input()) nums = sorted(list(map(int, input().split()))) result = [0] * (2 * N) list_pointer = 2 * N - 1 for index in range(list_pointer, -1, -2): result[index] = nums[list_pointer] list_pointer -= 1 store_pointer = 0 for index in range(li...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
n = int(input()) for _ in range(n): p = int(input()) t = [int(j) for j in input().split()] t.sort() ls = t[p : 2 * p] d = int((p - 1) / 2) print(ls[d]) q = list() for i in range(p): q.append(t[i]) q.append(ls[i]) print(*q)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l.sort() m = l[n:] m = m[n // 2] print(m) l2 = [] for i in range(n): l2.append(l[i]) l2.append(l[2 * n - i - 1]) print(*l2)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR E...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for i in range(int(input())): n = int(input()) l = [int(x) for x in input().split()] l.sort() l2 = l[: len(l) // 2] l1 = l[len(l) // 2 :] print(l1[len(l1) // 2]) for i in range(n): print(l2[i], l1[i], end=" ") print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() a, b = a[: n // 2 * 2], a[n // 2 * 2 :] c = [] for i in range(len(b) // 2): c.append(b[i]) c.append(b[i + n // 2 + 1]) print(c[1]) print(" ".join(str(x) for x in a + c))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l.sort(reverse=True) x = [0] * (2 * n) c = 0 for j in range(2 * n - 1, -1, -2): x[j] = l[c] c += 1 for j in range(2 * n - 2, -1, -2): x[j] = l[c] c += 1 c = n // 2 ans =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER ASSI...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
x = int(input()) for i in range(0, x): y = int(input()) q = list(map(int, input().strip().split(" "))) q.sort() m = q[y : 2 * y] ans = m[y // 2] print(ans) for i in range(0, y, 2): t = q[i] q[i] = q[y] q[y] = t y = y + 2 for u in range(0, len(q) - 1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) for k in range(t): n = int(input()) a = list(map(int, input().split(" "))) if n == 1: print(max(a[0], a[1])) for i in range(len(a)): print(a[i], end=" ") print() else: a.sort() b = [] j = 0 for i in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def CreateDic(nums): dic = dict() for i in nums: if not i in dic: dic[i] = 1 else: dic[i] += 1 return dic for _ in range(int(input())): n = int(input()) nums = list(map(int, input().split())) nums.sort() numsA = [] for i in range(1, n + 1): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NU...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
n = int(input()) while n: n -= 1 N = int(input()) l = [int(x) for x in input().split()] b = [] l.sort() for i in range(N): b.append(l[i]) b.append(l[N + i]) print(b[N]) print(*b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_C...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for i in range(int(input())): n = int(input()) x = input() x = list(map(int, x.split())) x.sort() y = x[n:] print(y[n // 2]) i = 0 while i < n: print(x[i], x[n + i], end=" ") i += 1 print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
tc = int(input()) for i in range(tc): b = [] n = int(input()) a = [int(i) for i in input().split()] a.sort() k = 2 * n if n == 1: print(a[1]) print(" ".join(map(str, a))) else: x = 1 y = n while x < y: tmp = a[x] a[x] = a[y] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
n = int(input()) while n > 0: c = int(input()) a = list(map(int, input().split())) b = sorted(a) lb = len(b) mid = int(c) median = int(2 * c - (c + 1) / 2) print(b[median]) b[mid], b[median] = b[median], b[mid] for i in range(c - 1): if i % 2 != 0: b[i - 1], b[lb ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP VAR NUM...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def cal(): T = int(input()) for _ in range(T): n = int(input()) A1 = list(map(int, input().split())) A = sorted(A1) if n % 2 == 1: print(A[n + int(n / 2)]) else: print(max(A[n + int(n / 2)], A[n + int(n / 2) - 1])) for i in range(n): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
test = input() test = int(test) for j in range(0, test): n = input() n = int(n) list2 = [] list3 = [] list4 = [] list2 = list(map(int, input().strip().split(" "))) list2.sort() print(list2[len(list2) - n // 2 - 1]) j = len(list2) - 1 for i in range(0, n, 2): list2[i], lis...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_O...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t: n = int(input()) x = n y = n + int(n / 2) l = list(map(int, input().split())) p = [] q = [] l.sort() z = l[y] for i in range(x, 2 * n): p.append(l[i]) for i in range(0, x): q.append(l[i]) q.append(p[i]) print(z) for i in q...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t: n = int(input()) l = list(map(int, input().split())) l.sort() l2 = l[n : 2 * n] mid = n // 2 print(l2[mid]) for i in range(0, n): print(l[i], end=" ") print(l2[i], end=" ") print("\n", end="") t = t - 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t > 0: n = int(input()) l = list(map(int, input().split())) l = sorted(l) output = [] a = l[:n] b = l[n:] list(output.extend(i) for i in zip(a, b)) alpha = int((n - 1) / 2) print(b[alpha]) output = " ".join(map(str, output)) print(output) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR F...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) for i in range(t): s = int(input()) arr = list(map(int, input().split())) arr.sort() hold = int(s / 2) print(arr[2 * s - 1 - hold]) for j in range(s): print(arr[j], arr[2 * s - 1 - j], end=" ", sep=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR FOR VAR FUNC_CALL VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) a = sorted(list(map(int, input().split()))) mdn = a[n + n // 2] b = [] for i in range(n): b.append(a[i]) b.append(a[n + i]) print(mdn) print(*b)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
import sys for i in range(int(sys.stdin.readline())): n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) a.sort() sys.stdout.write(str(a[n:][int((n - 1) / 2)]) + "\n") for j in range(n): sys.stdout.write(str(a[j]) + " " + str(a[n + j]) + " ") sys.stdout.write...
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_C...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n, a = int(input()), sorted([int(x) for x in input().split()]) c = [] for i in range(n): c.append(a[i]) c.append(a[n + i]) print(c[2 * (n // 2) + 1]) print(*c)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBE...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for t in range(int(input())): n = int(input()) a = [int(i) for i in input().split()] sa = sorted(a) b = [] c = [] for i in range(n, 2 * n): b.append(sa[i]) for i in range(0, n): c.append(sa[i]) print(b[n // 2]) for i in range(0, n): print(c[i], b[i], end=" ") ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def compose_list(l_idx, sub_len, r_idx, t_list): new_list = [] for iterv in range(sub_len): new_list.append(t_list[l_idx]) l_idx += 1 new_list.append(t_list[r_idx]) r_idx += 1 return new_list t_num = int(input()) for t_iter in range(t_num): t_len = int(input()) twic...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP VAR FUNC...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
t = int(input()) while t > 0: n = int(input()) l = list(map(int, input().split())) l.sort(reverse=True) b, c = l[0 : len(l) // 2], l[len(l) // 2 :] d = [] for i in range(len(b)): d.append(b[i]) d.append(c[i]) print(b[len(b) // 2]) for i in range(len(d)): print(d[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for t in range(int(input())): n = 2 * int(input()) A = list(map(int, input().split())) A = list(sorted(A)) Alow = A[: n // 2] Ahigh = A[n // 2 :] median = Ahigh[n // 4] B = [] for i in range(n // 2): B.append(Alow[i]) B.append(Ahigh[i]) print(median) print(*B)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN V...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
for _ in range(int(input())): n = int(input()) Ai = list(map(int, input().split())) Ai.sort() Aip = [] for i in range(n): Aip.extend([Ai[i], Ai[n + i]]) print(Aip[n]) print(*Aip)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given an array A of size 2 * N consisting of positive integers, where N is an odd number. You can construct an array B from A as follows, B[i] = max(A[2 * i - 1], A[2 * i]), i.e. B array contains the maximum of adjacent pairs of arr...
def partition(arr, low, high): i = low - 1 pivot = arr[high] for j in range(low, high): if arr[j] <= pivot: i = i + 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quickSort(arr, low, high): if low < high: ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR E...
Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s. ...
import sys input = sys.stdin.readline N = int(200000.0 + 1) n, k, s, t = map(int, input().split()) car = [list(map(int, input().split())) for _ in range(n)] g = sorted(list(map(int, input().split()))) + [0] g[k] = s - g[k - 1] for i in range(k - 1, 0, -1): g[i] -= g[i - 1] def is_valid(g, k, v, t): need = 0 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBE...
Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s. ...
import sys def roadToCinema(V, S, T, stations): m = len(stations) t = 0 stations.append(S) prev = 0 for cur in stations: dis = cur - prev if dis > V: return False else: t += max(dis * 3 - V, dis) if t > T: return False pre...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split(" ")) def met(x, n, k): k -= 1 r = n - k k = min(k, x - 1) r = min(r, x) return (2 * x - k - 1) * k // 2 + (2 * x - r + 1) * r // 2 def busqueda_binaria(l, r): if l > r: return r mitad = (l + r) // 2 if met(mitad, n, k) <= m: return bu...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VA...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) def quiero(s): ne = s + (s - 1) * s if s > k: d = s - k ne -= d * (d + 1) // 2 if s + k - 1 > n: d = s + k - n - 1 ne -= d * (d + 1) // 2 return ne lo, hi = 0, m while hi > lo: mid = (hi + lo + 1) // 2 if n + quiero(mid) <= ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) l = 0 r = int(1000000000000.0) while r - l > 1: x = (r + l) // 2 if x >= k: sum1 = x * (k - 1) - k * (k - 1) // 2 else: t = x - 1 sum1 = t * x - t * (t + 1) // 2 + k - 1 - t k1 = n - k + 1 if x >= k1: sum2 = x * (k1 - 1) - k1 * (k1 ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, k, my = map(int, input().split()) def distribute(l, r, c): if l > r: return 0 x = r - l + 1 if x > c: x = c return x * (x + 1) // 2 + (c - x) * x def givable(cc): return distribute(1, my - 1, cc - 1) + distribute(my + 1, n, cc - 1) + cc <= k Ans = 1 k = k - n high, low, mid,...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = list(map(int, input().split(" "))) extra = m - n maxi = 1 if n == 1: print(m) elif n == 2: if m % 2 == 0: print(m // 2) else: print(m // 2 + 1) else: for i in range(extra): stepPillows = 1 + min(k - 1, i) + min(n - k, i) if extra >= stepPillows: extr...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR A...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def check(x): s = 0 if x - 1 <= n - k: sr = x * (x - 1) // 2 + n - k - x + 1 else: sr = x * (x - 1) // 2 - (x - (n - k + 1)) * (x - (n - k + 1) + 1) // 2 if x - 1 <= k - 1: sl = x * (x - 1) // 2 + k - x else: sl = x * (x - 1) // 2 - (x - (k - 1)) * (x - (k - 1) - 1) /...
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR N...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) m -= n k -= 1 frodo = 1 left = right = k while True: needed = right - left + 1 if m >= needed: frodo += 1 m -= needed left = max(0, left - 1) right = min(n - 1, right + 1) if left == 0 and right == n - 1: frodo += m // n ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR NU...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
R = lambda: map(int, input().split()) n, p, k = R() l, r = 1, p while l < r: m = (l + r + 1) // 2 cl = (m + max(1, m - k + 1)) * min(k, m) // 2 + max(k - m, 0) cr = (m + max(1, m - (n - k))) * min(n - k + 1, m) // 2 + max(n - k + 1 - m, 0) if cl + cr - m <= p: l = m else: r = m - 1 p...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR BIN_...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = [int(x) for x in input().split()] if n == 1: print(m) else: m -= n extra = 0 while m > min(k - 1, extra) + min(n - k, extra): m -= min(k - 1, extra) + min(n - k, extra) + 1 extra += 1 print(1 + extra)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER E...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def is_ok(x, y): if y > x - 1: val = ((x - 1) * x >> 1) + y - (x - 1) else: val = y * (x - 1 + x - y) >> 1 return val hobbits, pillows, k = [int(x) for x in input().split()] l = 1 r = pillows while l <= r: m = l + r >> 1 valor = is_ok(m, k - 1) + is_ok(m, hobbits - k) + m if va...
FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR V...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) k1 = n - k + 1 def case(x): res = x if k == x: res += x * (x - 1) // 2 elif k > x: res += x * (x - 1) // 2 + k - x else: res += x * (x - 1) // 2 - (x - k) * (x - k + 1) // 2 if k1 == x: res += x * (x - 1) // 2 elif k1 > x: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) l, r = int(0), m while l + 1 < r: mid = (l + r) // 2 lpos = max(1, k - mid + 1) lcnt = (mid - (k - lpos) + mid) * (k - lpos + 1) // 2 rpos = min(n, k + mid - 1) rcnt = (mid - (rpos - k) + mid) * (rpos - k + 1) // 2 if lcnt + rcnt - mid > m - n: r = mid...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) ans = 1 m -= n osn = 0 while m > 1: if osn == max(k - 1, n - k): break ans += 1 m -= 1 osnl, osnr = min(k - 1, osn), min(n - k, osn) osn += 1 m -= osnl + osnr ans += m // n print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
import sys def check1(l, r, m): if m == 0: return l if l >= r - 1: return l + 1 mid = int((l + r) // 2) last = 2 * mid + 1 sr = (1 + last) * (mid + 1) / 2 if m >= sr: return check1(mid, r, m) return check1(l, mid, m) def check2(first, l, r, m): if l >= r - 1: ...
IMPORT FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = list(map(int, input().split())) l, r = 1, 10**9 + 1 def ok(p): rs = 0 if k >= p: rs += p * (p + 1) // 2 rs += k - p else: rs += p * (p + 1) // 2 f = p - k rs -= f * (f + 1) // 2 if p - 1 <= n - k: rs += p * (p - 1) // 2 rs += n - k - p ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def bin_search(l, r, func): while l < r: c = (l + r) // 2 val = func(c) if l + 1 == r: if func(r): return r if func(l): return l if val: l = c else: r = c - 1 if l == r: return l e...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR RETURN VAR IF FUNC_CALL VAR VAR RETURN VAR IF VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN VAR RETURN NUMBER FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
[n, m, k] = list(map(int, input().split())) m -= n lo = 0 hi = m while lo < hi: x = (lo + hi + 1) // 2 need = x * x if k < x: need -= (x - k) * (x - k + 1) // 2 if k + x > n: need -= (k + x - 1 - n) * (k + x - n) // 2 if need <= m: lo = x else: hi = x - 1 print(lo...
ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) m -= n def valid(x): a = min(k - 1, x - 1) b = min(n - k, x - 1) s1 = a * (x - 1 + x - a) // 2 s2 = b * (x - 1 + x - b) // 2 return s1 + s2 + x <= m l, r = 0, 1 << 62 while r > l + 1: mid = l + r >> 1 if valid(mid): l = mid else: r ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) m -= n soon = False summ = 0 g = 1 i = 0 for i in range(1, 1 + min(n - k, k - 1)): summ += g g += 2 if summ > m: soon = True break if not soon: for i in range(1 + min(n - k, k - 1), 1 + max(n - k, k - 1)): summ += g g += 1 if su...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBE...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = map(int, input().split()) m -= n l, u, x = k, k, 1 while m > 0 and (u < n or l > 1): x += 1 m -= u - l + 1 if l > 1: l -= 1 if u < n: u += 1 print(x + m // n)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def num(t): t = t - 1 r = t * t + n if t >= k: r -= max(0, (t - k) * (t - k + 1) // 2) if t >= n - k + 1: r -= max(0, (t - (n - k + 1)) * (t - (n - k)) // 2) return r s = input().split() n = int(s[0]) m = int(s[1]) k = int(s[2]) lo = 1 hi = 10**9 + 10 while lo < hi: mid = (lo +...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR NUM...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
n, m, k = input().split() n = int(n) m = int(m) k = int(k) m = m - n k = k - 1 def verif(n, m, k, r): a = r - k b = r - (n - 1) + k if a > 0: u = (r - a + 1) * (a + r) // 2 else: u = r * (r + 1) // 2 if b > 0: v = (r - b + 1) * (b + r) // 2 else: v = r * (r + 1)...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def f(n, m, k, x): k1 = k - 1 k2 = n - k if k1 > x - 1: ll = (x - 1) * x // 2 + (k1 - x + 1) else: ll = x * k1 - k1 * (k1 + 1) // 2 if k2 > x - 1: rr = (x - 1) * x // 2 + (k2 - x + 1) else: rr = x * k2 - k2 * (k2 + 1) // 2 return rr + ll + x <= m iarr = list...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP V...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def read_input(): line = input().strip().split() n = int(line[0]) m = int(line[1]) k = int(line[2]) p = m - n k = max(n - k + 1, k) y1 = k * (k - 1) // 2 y2 = (n - k) * (3 * k - 3 - n) // 2 y = y1 + y2 l = 1 if p >= y: l += k - 1 p -= y l += p // n ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BI...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def calculate_need(x, l, r): if l > x - 1: tl = (x - 1) * x // 2 + l - x + 1 else: tl = (x - 1 + x - l) * l // 2 if r > x - 1: tr = (x - 1) * x // 2 + r - x + 1 else: tr = (x - 1 + x - r) * r // 2 t = tl + tr + x return t def codeforces(n, m, k): l = k - 1 ...
FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER ASSIG...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def f(tar, n, m, k): p = 0 if k == 1 or k == n: y = n - 1 if y > tar - 1: a = tar * (tar - 1) // 2 b = y - (tar - 1) p += a + b else: p += (tar - 1 + tar - y) * y // 2 else: y1 = k - 1 if y1 > tar - 1: a = ta...
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def check(x, n, m, k): a = 0 if k - 1 > x - 1: a += x * (x - 1) // 2 + k - x else: a += (2 * x - k) * (k - 1) // 2 b = 0 if n - k > x - 1: b += x * (x - 1) // 2 + n - k - x + 1 else: b += (2 * x - n + k - 1) * (n - k) // 2 if a + b + x <= m: return Tru...
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VA...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
hobbit, pillow, bed = map(int, input().split()) pillow -= hobbit start = 0 end = pillow while start < end: mid = round((start + end + 1) / 2) lside = int(min(bed - 1, mid - 1)) rside = int(min(hobbit - bed, mid - 1)) needed = ( mid + lside * (mid - lside + (mid - 1)) / 2 + rside ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def pillows(n, k, h): p = (h - 1) * h + h left = 0 if k < h: left = (h - k) * (h - k + 1) // 2 right = 0 if n - k + 1 < h: right = (h - (n - k + 1)) * (h - (n - k + 1) + 1) // 2 return p - left - right def solve(n, m, k): p = m - n if p == 0: return 1 l = 0 ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def just_sum(n): return n * (n + 1) // 2 def get_sum(a, b): return just_sum(b) - just_sum(a - 1) def check(mid, k, n, sn): left = k - 1 right = n - k if left < mid: left_sum = get_sum(mid - left, mid - 1) else: left_sum = just_sum(mid - 1) if right < mid: right_su...
FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR A...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
from sys import stdin __author__ = "zihaozhu" def summation(a, b): if a > b: return summation(b, a) return (b + a) * (b - a + 1) / 2 hobbits, pillow, frodo = map(int, stdin.readline().split()) lo = 1 hi = pillow maxpossible = pillow - hobbits while lo < hi: mid = (lo + hi) // 2 left = max(0...
ASSIGN VAR STRING FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN ...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
import sys def is_able(n, m, k, mid): res = 0 if k < mid: res += (mid + mid - k + 1) * k // 2 else: res += mid * (mid + 1) // 2 + k - mid right = n - k + 1 if right < mid: res += (mid + mid - right + 1) * right // 2 else: res += mid * (mid + 1) // 2 + right - mi...
IMPORT FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP...
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h...
def _sum_n(n): return int(n * (n + 1) // 2) def _sum(p, k): return _sum_n(p) - (_sum_n(p - k) if p > k else p - k) def _solve(): n, m, k = map(int, input().split()) low, high = 1, 2000000000.0 while low < high: mid = int((low + high) // 2) sum = int(_sum(mid, k) + _sum(mid - 1, n...
FUNC_DEF RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VA...