description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) A = [input() for i in range(n)] for i in range(n - 1, 0, -1): if A[i] < A[i - 1]: p = 0 while p < len(A[i]) and A[i - 1][p] <= A[i][p]: p += 1 A[i - 1] = A[i - 1][:p] print("\n".join(A))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMB...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
from sys import stdin, stdout n = int(stdin.readline()) challengers = [] for i in range(n): challengers.append(stdin.readline().strip()[1:]) for i in range(n - 2, -1, -1): for j in range(min(len(challengers[i]), len(challengers[i + 1]))): if challengers[i][j] < challengers[i + 1][j]: break ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
import sys input = sys.stdin.readline n = int(input()) a = [] for i in range(n): s = input() s = s[: len(s) - 1] a.append(s) for i in range(n - 2, -1, -1): l, r = a[i], a[i + 1] for j in range(len(l)): if j >= len(r) or l[j] > r[j]: a[i] = l[:j] break elif l[...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR F...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) a = [input() for i in range(n)] for i in range(n - 1, 0, -1): b = a[i] c = a[i - 1] l1 = len(b) l2 = len(c) for j in range(min(l1, l2)): if b[j] < c[j]: a[i - 1] = c[:j] break elif b[j] > c[j]: break else: if l2 > l1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR ASSIGN ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
def cut_to_lexicographic(word_bigger, word_smaller): for l in range(len(word_bigger[: len(word_smaller)])): if word_bigger[l] != word_smaller[l]: return word_smaller[:l] return word_bigger[: len(word_smaller)] n = int(input()) array = [str(input()) for c in range(n)] b = n - 2 while b > -1...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN VAR VAR RETURN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) inp = [0] * n for i in range(n): inp[i] = input() def common_str(a, b): l = 1 for i in range(1, len(a)): if a[i] != b[i]: break l += 1 return a[:l] for i in range(n - 1, 0, -1): if inp[i] < inp[i - 1]: inp[i - 1] = common_str(inp[i], inp[i - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
import sys input = sys.stdin.readline def gcd(a, b): if a == 0: return b return gcd(b % a, a) def lcm(a, b): return a * b / gcd(a, b) def main(): n = int(input()) a = [] for i in range(n): s = input() a.append([len(s) - 2, s]) ans = 0 for i in range(n - 1, ...
IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR VAR ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) ss = [input().strip() for _ in range(n)] def compare_and_truncate(s1, s2): if s1 > s2: i = 0 while i < len(s2) and s1[i] == s2[i]: i += 1 return s1[:i] return s1 for i in range(len(ss) - 2, -1, -1): ss[i] = compare_and_truncate(ss[i], ss[i + 1]) ans =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
from sys import stdin, stdout def ri(): return list(map(int, input().split())) n = int(input()) s = [] for i in range(n): s.append(stdin.readline().strip()) for i in range(n - 1, 0, -1): if s[i - 1] <= s[i]: continue else: mind = min(len(s[i]), len(s[i - 1])) for j in range(m...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
def cnt(a, b): ln = 0 l = 0 r = len(a) - 1 if a > b: while r > l + 1: mid = (l + r) // 2 if a[: mid + 1] > b: r = mid else: l = mid a = a[: l + 1] return a n = int(input()) s = [] for i in range(n): b = input()...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
def sortHashtags(htags): def shorten(j, i): s = 0 while s < len(htags[i]) and htags[i][s] == htags[j][s]: s += 1 htags[j] = htags[j][:s] n = len(htags) for i in range(n - 1, 0, -1): if htags[i - 1] > htags[i]: shorten(i - 1, i) return "\n".join(h...
FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL STRING VAR ASSIG...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
def g(c, d): s = 0 while s < len(a[d]) and a[c][s] == a[d][s]: s += 1 a[c] = a[c][:s] def f(a): for i in range(len(a) - 1, 0, -1): if a[i - 1] > a[i]: g(i - 1, i) print("\n".join(a)) n = int(input()) a = [input() for i in range(n)] f(a)
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN V...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) tags = [] for i in range(n): tags.append(input()) for i in range(n - 2, -1, -1): curr = tags[i] next = tags[i + 1] for c in range(min(len(curr), len(next))): if curr[c] != next[c]: if curr[c] > next[c]: tags[i] = curr[:c] break else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VA...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
def compareHesh(heshBottom, heshTop): lenB, lenT = len(heshBottom), len(heshTop) flag = True for i in range(1, lenT): if i + 1 > lenB: return i elif heshTop[i] > heshBottom[i]: return i elif heshTop[i] < heshBottom[i]: return 0 return 0 numbe...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR RETURN VAR IF VAR VAR VAR VAR RETURN VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL ...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
from sys import stdin, stdout n = int(stdin.readline()) A = [0] * n for j in range(n): A[j] = stdin.readline().strip() answer = [0] * n answer[-1] = A[-1] for j in range(n - 2, -1, -1): if A[j] <= answer[j + 1]: answer[j] = A[j] else: for i in range(min(len(answer[j + 1]), len(A[j]))): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR F...
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
n = int(input()) l = [] for i in range(n): l.append(input()) def lexi(i): j = 1 while j < len(l[i]) and l[i - 1][j] == l[i][j]: j += 1 l[i - 1] = l[i - 1][:j] for i in range(n - 1, 0, -1): if l[i - 1] > l[i]: lexi(i) print("\n".join(l))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUM...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): p, q, r = 0, 20000, 1 n = int(input()) l = [] for i in range(n): l.append(list(map(int, input().split()))) l.sort() for i in l: if i[0] > q: r += 1 p, q = i else: p = i[0] q = min(q, i[1]) p...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def solve(intervals): intervals.sort(key=lambda x: x[1]) cnt = 0 stack = [intervals[0]] for i in range(1, len(intervals)): curr = intervals[i] if stack and curr[0] <= stack[-1][-1]: ps, pe = stack.pop() stack.append([max(ps, curr[0]), min(pe, curr[-1])]) e...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for t in range(int(input())): n = int(input()) a = [] for i in range(n): a.append(list(map(int, input().split()))) a.sort() m = 1 x = a[0][1] for i in a[1:]: s = i[0] e = i[1] if s > x: m += 1 x = e else: x = min(x, ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): n = int(input()) vp = [] for i in range(n): a, b = map(int, input().split()) vp.append((a, b)) ans = 1 vp.sort(key=lambda x: x[1]) mx = vp[0][1] for it in range(1, n): if vp[it][0] > mx: ans += 1 mx = vp[it][1] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
T = int(input()) arr = [-1] * 2003 for i in range(T): arr = [-1] * 2003 lst = 0 fst = 0 N = int(input()) for j in range(N): x, y = map(int, input().split()) arr[y] = max(arr[y], x) lst = max(lst, y) fst = min(fst, y) mx = -1 ans = 0 for i in range(fst, lst...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CAL...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
t = int(input()) for tt in range(t): n = int(input()) dim = [] for nn in range(n): s, e = map(int, input().split()) dim.append((e, s)) dim.sort() ans = 1 fi, se = dim[0] for e, s in dim: if s <= fi: ans = ans else: fi = e an...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for z in range(int(input())): n = int(input()) a = [] for i in range(n): a.append([int(x) for x in input().split()]) a.sort(key=lambda x: x[1]) x = 1 m = a[0][1] for i in range(1, n): if a[i][0] > m: m = a[i][1] x += 1 print(x)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUM...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): k = [] for _ in range(int(input())): k.append([int(i) for i in input().split()]) k = sorted(k) last_val = k[0][1] count = 1 for i in range(1, len(k)): if k[i][0] <= last_val: if k[i][1] < last_val: last_val = k[i][1] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBE...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def min_bombs(interval): interval = sorted(interval) count = 0 last = None for start, end in interval: if last is None: last = start, end elif start > last[1]: count += 1 last = start, end elif end < last[1]: last = start, end ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR VAR IF VAR NONE ASSIGN VAR VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): k = [] for i in range(int(input())): k.append(list(map(int, input().split()))) k.sort(key=lambda x: x[0], reverse=True) bomb = 1 min = k[0][0] for j in range(1, len(k)): if min > k[j][1]: bomb += 1 min = k[j][0] print(bomb...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VA...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
t = int(input()) for i in range(t): n = int(input()) a = [] for j in range(n): l = list(map(int, input().split())) a.append(l) a.sort() b = 0 c = 0 while c < n: b += 1 x = a[c][0] y = a[c][1] j = c + 1 while j < n: if y >= a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSI...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
m = int(input()) for t in range(m): n = int(input()) a = [] for i in range(n): a.append(list(map(int, input().split()))) a.sort() c = 0 temp = None for i in a: if temp is None: temp = i elif i[0] > temp[1]: c += 1 temp = i e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR VAR IF VAR NONE ASSIGN VAR VAR IF VAR ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def oneDimensionalKingdom(arr, n): arr.sort(key=lambda x: x[1]) ans = 1 last = arr[0][1] first = arr[0][0] for i in range(1, n): if arr[i][0] > last: ans += 1 first = arr[i][0] last = arr[i][1] return ans t = int(input()) for _ in range(t): n = i...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
t = int(input()) for f in range(t): n = int(input()) a = [] x = 0 y = 10000000 count = 1 for i in range(n): a.append(list(map(int, input().split()))) a.sort() for k in a: if k[0] > y: count += 1 y = k[1] else: y = min(k[1], y) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def ss(l): n = len(l) l = sorted(l, key=lambda x: x[1]) ans = 0 b = -float("inf") for i in range(n): x, y = l[i] if x > b: ans += 1 b = y return ans for _ in range(int(input())): n = int(input()) l = [] for i in range(n): l.append(lis...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def li(): return list(map(int, input().split())) def si(): return input().split() def ii(): return int(input()) def ip(): return input() for tastcas in range(int(input())): n = ii() k = n a = [] bomb = 1 for i in range(n): a.append(tuple(li())) a.sort(key=lambda x...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FU...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def destryKingdoms(): t = int(input()) for _ in range(t): n = int(input()) kingdoms = [] for i in range(n): kingdoms.append(list(map(int, input().split()))) kingdoms.sort(key=lambda x: (x[0], x[1])) r = kingdoms[0][1] count = 0 for i in range(1...
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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FO...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
t = int(input()) for _ in range(t): n = int(input()) a = [] for _ in range(n): a.append(list(map(int, input().split()))) a.sort() count = 1 f1, s1 = a[0][0], a[0][1] for i in range(len(a)): if a[i][0] <= s1: f1 = a[i][0] s1 = min(s1, a[i][1]) e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER FOR VAR FUN...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
T = int(input()) for t in range(T): N = int(input()) kingdoms = [[int(x) for x in input().split()] for n in range(N)] kingdoms.sort(key=lambda x: x[1]) ans = 0 newmax = -1 for i in range(len(kingdoms)): if kingdoms[i][0] > newmax: ans += 1 newmax = kingdoms[i][1] ...
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 VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBE...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): n = int(input()) res = [] for i in range(n): a, b = map(int, input().split()) res.append([a, b]) res = sorted(res, key=lambda x: x[1]) p, q = 0, 100000 cont = 1 for i in res: if i[0] > q: cont += 1 p, q = i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR I...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def main(): for _ in range(int(input())): kingdoms = sorted( [[int(a) for a in input().split(" ")] for _ in range(int(input()))] ) i = kingdoms[0][0] j = kingdoms[0][-1] bombs = 1 for a in kingdoms[1:]: if a[0] > j: i = a[0] ...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER AS...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for t in range(0, int(input())): n = int(input()) count = 0 arr = [] for i in range(0, n): a, b = map(int, input().split()) arr.append([a, b]) arr.sort(key=lambda x: x[1]) k = -1 for i in range(0, n): a = arr[i][0] b = arr[i][1] if a > k: c...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
T = int(input()) for i in range(T): N = int(input()) array = [] for j in range(N): l = input() array.append([int(i) for i in l.split()]) array = sorted(array) count = 1 point = array[0][1] for j in range(1, N): if array[j][0] <= point: point = min(point, a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL ...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
t = int(input()) while t: n = int(input()) kingdoms = [] for i in range(n): kingdoms.append(list(map(int, input().split()))) kingdoms.sort(key=lambda x: x[1]) curr = 0 nex = 1 bombs = 0 while curr < n: while kingdoms[nex][0] <= kingdoms[curr][1]: nex += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR NUM...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for i in range(int(input())): a = [] for j in range(int(input())): a.append(input().split()) a[-1][0] = int(a[-1][0]) a[-1][1] = int(a[-1][1]) a.sort() stack = [] numb = 1 queue = [] minv = a[0][1] k = 0 for i in range(1, len(a)): if a[i][0] > minv: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR N...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
for _ in range(int(input())): n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) l.append([a, b]) l.sort() s = l[0][0] e = l[0][1] b = 0 for i in range(1, n): if l[i][0] <= e: s = l[i][0] if l[i][1] <= e: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR V...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
try: t = int(input()) for _ in range(t): n = int(input()) dictk = [-1] * 2001 for o in range(n): a, b = map(int, input().split()) dictk[b] = max(dictk[b], a) maxk = -1 res = 0 for i in range(0, 2001): if maxk < dictk[i]: ...
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 LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def minBombs(kds): bombs = 0 end = kds[0][1] for kd in kds[1:]: if kd[0] > end: bombs += 1 end = kd[1] else: end = min(end, kd[1]) bombs += 1 return bombs T = int(input()) for t in range(T): N = int(input()) kds = [] for n in range(N)...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER 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 LIST FOR VAR FUNC...
Read problems statements in Mandarin Chinese and Russian. N one dimensional kingdoms are represented as intervals of the form [a_{i} , b_{i}] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum nu...
def printMinBombs(intervals, n): total = n ps, pe = -1, -1 for interval in intervals: if pe == -1: ps, pe = interval elif interval[0] <= pe: total -= 1 if interval[1] <= pe: pe = interval[1] else: ps, pe = interval r...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR 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 FOR...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) l = [int(i) for i in input().split()] l = [[l[i], i] for i in range(n)] l.sort(reverse=1) a = 0 b = 0 one = [] two = [] for i in range(n): if i % 2 == 0: a += l[i][0] one.append(l[i][1] + 1) else: b += l[i][0] two.append(l[i][1] + 1) print(len(one)) print(*one) p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER EXPR FU...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) arr = [int(x) for x in input().split()] p = [] for i, x in enumerate(arr): p.append([x, i + 1]) p.sort() a = [] b = [] for i, x in enumerate(p): if i % 2 == 0: a.append(str(x[1])) else: b.append(str(x[1])) print(len(a)) print(" ".join(a)) print(len(b)) print(" ".join(b))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) arr = list(map(int, input().split())) idx = [i for i in range(n)] idx.sort(key=lambda i: arr[i]) print(n // 2) for i in range(n // 2): print(idx[2 * i + 1] + 1, end=" ") print() print(n - n // 2) for i in range(n - n // 2): print(idx[2 * i] + 1, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER STRI...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) guys = list(map(int, input().split())) guys = list(enumerate(guys)) guys.sort(key=lambda x: x[1], reverse=True) team1 = [] skill1 = 0 team2 = [] skill2 = 0 for number, skill in guys: if skill1 > skill2: if len(team2) - len(team1) >= 1: team1.append(number + 1) skill1...
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL V...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
b = [] f = [] s = [] n = int(input()) a = list(map(int, input().split())) for i in range(n): b.append((a[i], i + 1)) c = 0 for i in sorted(b): if not c % 2: f.append(i) else: s.append(i) c += 1 print(len(f)) for i in f: if i != f[len(f) - 1]: print(i[1], end=" ") else: ...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FU...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
class Player: def __init__(self, id, skill): self.id = id self.skill = skill def __eq__(self, other): return self.id == other.id def __lt__(self, other): return self.skill < other.skill def __repr__(self): return str(self.skill) class Team: def __init__...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CAL...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
import sys input = sys.stdin.buffer.readline I = lambda: list(map(int, input().split())) (n,) = I() l = I() ll = [] f = {} for i in range(n): ll.append([l[i], i]) f[i] = l[i] ll.sort(reverse=True) x = [] y = [] xs = 0 ys = 0 xm = max(l) for i in range(n): if i % 2 == 0: x.append(ll[i][1]) x...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) for _ in range(1): n = nmbr() a = sorted(zip(lst(), range(1, 1 + n)), reverse=1) team1 = [] team2 = [] for i in range(n): if i & 1: team1 += [a[i][1]] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) ar = list(map(int, input().split())) ar1 = [] for i in range(n): ar1.append([ar[i], i]) ar1 = sorted(ar1) print((n + 1) // 2) for i in range(0, n, 2): print(ar1[i][1] + 1, end=" ") print() print(n // 2) for i in range(1, n, 2): print(ar1[i][1] + 1, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL V...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) arr = list(map(int, input().split())) arr = [(v, i + 1) for i, v in enumerate(arr)] arr.sort() left = arr[: n // 2] right = arr[n // 2 :] left_sum = sum([v for v, i in left]) right_sum = sum([v for v, i in right]) max_player = max([v for v, i in arr]) for i in range(n // 2): if abs(right_sum - left...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) p = list(map(int, input().split())) l = [] for i in range(n): l.append([p[i], i + 1]) l.sort() f = [l[0][1]] s = [l[1][1]] s1 = l[0][0] s2 = l[1][0] for i in range(2, n): if s1 > s2: s.append(l[i][1]) s2 = s2 + l[i][0] elif s2 > s1: f.append(l[i][1]) s1 = s1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
from sys import stdin def arr_enu(): return sorted( [[i + 1, int(x)] for i, x in enumerate(stdin.readline().split())], key=lambda x: x[1], ) n, a, team1, team2 = int(input()), arr_enu(), [], [] for i in range(n): if i % 2: team1.append(a[i][0]) else: team2.append(a[i]...
FUNC_DEF RETURN FUNC_CALL VAR LIST BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR LIST LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EX...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) l = [int(i) for i in input().split()] t = sorted(l) x = 0 y = 0 d = dict() for i in range(len(l)): if l[i] in d: d[l[i]].append(i + 1) else: d[l[i]] = [i + 1] a = [] b = [] for i in range(len(t)): if x < y: a.append(t[i]) x += t[i] else: b.append(...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR LIST BIN_OP VAR...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) lst = list(map(int, input().split())) d = {} for i, x in enumerate(lst): if d.get(x) == None: d[x] = [1] d[x].append(i + 1) lst.sort() x, y, X, Y = 0, 0, [], [] for i, item in enumerate(lst): if x <= y: X.append(d[item][d[item][0]]) x += item else: Y.appe...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR LIST NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER LIST LIST FOR VAR ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) arr = sorted([(int(x), i) for i, x in enumerate(input().split())]) print((len(arr) + 1) // 2) for i in arr[::2]: print(i[1] + 1, end=" ") print() print(len(arr) // 2) for i in arr[1::2]: print(i[1] + 1, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CAL...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
a = int(input()) z = list(map(int, input().split())) ans = [] for i in range(len(z)): ans.append([z[i], i]) ans.sort() flag = 0 tan = [] i = 0 one = [] two = [] while i < len(ans): if flag == 0: one.append(ans[i][1] + 1) i += 1 if i < len(ans): two.append(ans[i][1] + 1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR FUNC_CALL...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = list(map(int, input().split())) l = [] for i in range(n): l.append([a[i], i + 1]) l = sorted(l, key=lambda h: -1 * h[0]) a = [] b = [] for i in range(n): if i % 2 == 0: a.append(l[i][1]) else: b.append(l[i][1]) print(len(a)) print(*a) print(len(b)) print(*b)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
import sys sys.setrecursionlimit(1000000) def solve(): (n,) = rv() (ainput,) = rl(1) a = [(val, i) for i, val in enumerate(ainput)] a.sort() a = a[::-1] f, s = list(), list() for i in range(len(a)): if i % 2 == 0: f.append(a[i][1] + 1) else: s.appen...
IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_O...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
import sys def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() n = int(input()) Arr = get_array() myArr = [] for i in range(n): myArr.append((Arr[i], i ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VA...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) l = [(i, num + 1) for num, i in enumerate([int(j) for j in input().split()])] t1 = [] t2 = [] for ind, (_, num) in enumerate(sorted(l)): if ind % 2 == 0: t1.append(num) else: t2.append(num) print(len(t1)) for i in sorted(t1): print(i, end=" ") print() print(len(t2)) for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CA...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n, t = int(input()), list(map(int, input().split())) k = n // 2 a, b = t[:k], t[k:] u, v, m = sum(a), sum(b), max(t) a, b = list(enumerate(a, 1)), list(enumerate(b, k + 1)) i, d = 0, abs(u - v) - m if u > v: a, b = b, a while d > 0: if a[i][1] < b[i][1]: d -= 2 * (b[i][1] - a[i][1]) a[i], b[i] =...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR BI...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
import sys input = sys.stdin.readline for _ in range(1): n = int(input()) arr = [int(x) for x in input().split()] temp = [[arr[i], i] for i in range(n)] temp.sort() a, b = [], [] for i in range((n + 1) // 2): if i % 2 == 0: if i + 1 != n - i: a.append(temp[i]...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL 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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMB...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
def team(arr): base = [[arr[i], i + 1] for i in range(len(arr))] base = sorted(base, key=lambda s: s[0], reverse=True) t1 = [] t2 = [] while base: t1.append(base[0][1]) base.pop(0) if base: t2.append(base[0][1]) base.pop(0) print(len(t1)) print...
FUNC_DEF ASSIGN VAR LIST VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_C...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = list(map(int, input().split())) arr = [] for i in range(n): arr.append((a[i], i + 1)) arr.sort(reverse=True) t1 = [] t2 = [] sum1 = 0 sum2 = 0 ex = -1 if n % 2 == 1: ex = arr[n - 1][1] n -= 1 for i in range(0, n, 2): if arr[i][0] >= arr[i + 1][0]: mx = arr[i][0] mn =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR N...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
a = int(input()) b = input().split() b = sorted([[int(b[i]), str(i + 1)] for i in range(0, a)], reverse=True) c, d = [], [] sc, sd = 0, 0 while len(b) > 1: if sc > sd: d.append(b.pop()[1]) c.append(b.pop()[1]) else: c.append(b.pop()[1]) d.append(b.pop()[1]) if len(b): if sc >...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR NUMBER NUMBER WHILE FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL V...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = sorted([[int(j), i + 1] for i, j in enumerate(input().split())]) s = len(a[::2]) print(s, *[i[1] for i in a[::2]]) print(n - s, *[i[1] for i in a[1::2]])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR VAR NUMBER NUMBER
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = list(map(int, input().split())) m = max(a) temp = [(a[i], i + 1) for i in range(n)] temp.sort() teamsum = [0, 0] cnt = [0, 0] teams = [[], []] minpos = 0 i = n - 1 while cnt[0] < n // 2 and cnt[1] < n // 2: cnt[minpos] += 1 teamsum[minpos] += temp[i][0] teams[minpos].append(temp[i][1]) ...
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 VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR NUMBER ASS...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = map(int, input().split()) a = sorted(enumerate(a, 1), key=lambda x: x[1]) a = list(a) t1, t2 = [], [] first = True while len(a): if first: t1.append(a.pop()[0]) else: t2.append(a.pop()[0]) first = not first print(len(t1)) print(*t1) print(len(t2)) print(*t2)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = list(map(int, input().split())) a = [(a[i], i + 1) for i in range(n)] a.sort() lp = [a[x][1] for x in range(0, n, 2)] rp = [a[x][1] for x in range(1, n, 2)] print(len(lp)) print(*lp) print(len(rp)) print(*rp)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CA...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = [int(i) for i in input().split()] dic = {} for i in range(n): dic[a[i]] = [] for i in range(n): dic[a[i]].append(i + 1) a.sort() f = [] s = [] for i in range(n): if i & 1: f.append(dic[a[i]][-1]) else: s.append(dic[a[i]][-1]) dic[a[i]].pop() print(len(f)) print(*...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
class Player: def __init__(self, position, skill): self.position = position self.skill = skill n = int(input()) players = [Player(i + 1, x) for i, x in enumerate(map(int, input().split()))] players.sort(key=lambda player: player.skill) left, right = [], [] for i, player in enumerate(players): ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) i = 0 def f(a): global i i += 1 return a, i a = sorted(list(map(f, map(int, input().split())))) print(n // 2) for i in a[1::2]: print(i[1], end=" ") print() print(n - n // 2) for i in a[0::2]: print(i[1], end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR EXPR FUNC_...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) a = list(map(int, input().split())) di = {} for i in range(len(a)): di[i] = di.get(i, 0) + a[i] d = sorted(di.items(), key=lambda kv: (kv[1], kv[0])) dic = dict(d) list1 = list() list2 = list() i = 0 for keys in dic: if i % 2: list2.append(keys + 1) else: list1.append(keys +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FU...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
n = int(input()) arr = list(map(int, input().split())) x = [] y = [] sx = 0 sy = 0 i = 0 ml = [] z = 0 while z < n: ml.append([arr[z], z + 1]) z += 1 ml.sort() for k in ml: if sx <= sy: sx += k[0] x.append(k[1]) else: sy += k[0] y.append(k[1]) i += 1 print(len(x)) pri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ...
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
import sys def make_teams(array): arr_2 = sorted(range(len(array)), key=lambda k: array[k]) teams = [[], []] for i in range(len(array)): if i % 2 == 0: teams[0].append(arr_2[i] + 1) else: teams[1].append(arr_2[i] + 1) return teams def main(): n = sys.stdin...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSI...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a = sorted(a) b = sorted(b) b = b[::-1] temp = [] for i in range(n // 2, n): temp.append(a[i]) for i in range(0, n // 2): temp.append(a[i]) for i...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST F...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) for i in range(t): n = int(input()) l1 = list(map(int, input().split())) l2 = list(map(int, input().split())) l1.sort() l2.sort() l11 = l2[0 : n // 2] l2 = l2[n // 2 :] l2.reverse() l3 = [] l2 = l11 + l2 i = 0 while i < n: l3.append(l1[i] + l2[i])...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSI...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) for test in range(t): n = int(input()) b = list(map(int, input().split())) g = list(map(int, input().split())) b.sort() g.sort() i = (n - 1) // 2 j = n - 1 mn = float("inf") while i < n: mn = min(mn, b[i] + g[j]) i += 1 j -= 1 print(mn)
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER A...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) c = n // 2 a = list(map(int, input().split())) b = list(map(int, input().split())) if n == 1: print(a[0] + b[0]) continue b = sorted(b, reverse=True) a = sorted(a) s = [] ans = [] for i in range(c, n, 1): ans....
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): numberOfBoys = int(input()) listOfBoys = list(map(int, input().split())) listOfGirls = list(map(int, input().split())) listOfBoys.sort() listOfGirls.sort() listOfHappiness = [] medianPos = int(numberOfBoys / 2) for i in range(0, medianPos): listOfHap...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort() k = n // 2 l = [] for i in range(k, n): l.append(a[i] + b[n + k - i - 1]) l.sort() print(l[0])
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_C...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
def T(A, B): C = [] for i in range(len(A)): C.append(A[i] + B[i]) return C a = int(input()) for i in range(a): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) if N == 1: print(A[0] + B[0]) else: A.sort() B.sort() ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) ali = list(map(int, input().split())) bli = list(map(int, input().split())) ali.sort() bli.sort() k = n // 2 ali = ali[k:] bli = bli[k:] lst = list() ln = len(ali) for i in range(ln): a = ali[i] + bli[ln - i - 1] ...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR ...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort() res = float("inf") for i in range((n - 1) // 2, n): res = min(res, a[i] + b[n - 1]) n -= 1 print(res)
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_O...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] a = sorted(a) b = sorted(b) a1 = a[n // 2 :] b1 = b[n // 2 :] b1 = sorted(b1, reverse=True) temp = [] for i in range(len(a1)): x = a1[i] + b1[i...
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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR ...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
def solution(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort() B.sort() start = (N - 1) // 2 end = N - 1 median = 1e18 for i in range(start, N): median = min(median, A[i] + B[end]) end -= 1 print(median) t = int...
FUNC_DEF 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) for _ in range(t): n = int(input()) list1 = list(map(int, input().strip().split())) list2 = list(map(int, input().strip().split())) list1.sort() list2.sort() mid = n // 2 list1 = list1[mid:] list2 = list2[mid:] list1.sort(reverse=True) list3 = [(list1[i] + list2[...
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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NU...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
def mxmed(n, a, b): a.sort() b.sort() s = (n - 1) // 2 e = n - 1 med = 1e18 for i in range(s, n): med = min(med, a[i] + b[e]) e = e - 1 print(med) return t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) b = list(map(in...
FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) brr = list(map(int, input().split())) if n == 1: print(arr[0] + brr[0]) else: arr.sort() brr.sort() arr = arr[n // 2 :] brr = brr[n // 2 :][::-1] ans = float("inf") ...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL V...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) while t: n = int(input()) med = n // 2 a = sorted(map(int, input().split())) b = sorted(map(int, input().split())) new_b = b[0:med] + sorted(b[med:], reverse=True) c = [] for i in range(n): c.append(a[i] + new_b[i]) c = sorted(c) print(c[med]) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN ...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort() a = a[n // 2 :] b = b[n // 2 :] b = b[::-1] x = 9999999999 for i in range(n - n // 2): x = min(x, a[i] + b[i]) 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR ...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
t = int(input()) for i in range(t): n = int(input()) a = list(sorted(map(int, input().split()))) b = list(sorted(map(int, input().split()))) c = [] s = 0 for j in range(n // 2): c.append(a[s] + b[j]) s += 1 for k in range(n - 1, n // 2 - 1, -1): c.append(a[s] + b[k]) ...
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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for t in range(int(input())): n = int(input()) boys = [int(s) for s in input().split()] girls = [int(s) for s in input().split()] boys = sorted(boys) girls = sorted(girls) if n == 1: print(boys[0] + girls[0]) continue mid = (n - 1) // 2 ans = 1e19 end = n - 1 for ...
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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMB...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
import sys t = int(input()) for _ in range(t): n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] a.sort() b.sort() e = n - 1 ans = sys.maxsize for i in range(n // 2, n, 1): ans = min(ans, a[i] + b[e]) e -= 1 print(ans)
IMPORT 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 ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_...
N boys and N girls attend a dance class, where N is odd. For today's practice session, they need to form N boy-girl pairs. The i-th boy has a happiness value of A_{i} and the i-th girl has a happiness value of B_{i}. A pair consisting of the i-th boy and the j-th girl has a happiness value of A_{i} + B_{j}. Let the h...
for _ in range(int(input())): n = int(input()) l1 = sorted(map(int, input().split()))[n // 2 :] l2 = sorted(map(int, input().split()))[n // 2 :] r3 = min(sum(i) for i in zip(l1, l2[::-1])) print(r3)
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 BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ...