description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
n, d = map(int, input().split()) a, b = map(int, input().split()) a2 = [] for i in range(n): q, w = map(int, input().split()) a2.append((a * q + w * b, i)) a2.sort() ans = [] sumz = 0 for i in range(n): if sumz + a2[i][0] > d: break ans.append(a2[i][1]) sumz += a2[i][0] print(len(ans)) for i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR N...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
n, d = tuple([int(z) for z in input().split(" ")]) a, b = tuple([int(z) for z in input().split(" ")]) c_arr = list() for i in range(1, n + 1): f, g = tuple(int(z) for z in input().split(" ")) t_arr = [f * a + g * b, i] c_arr.append(t_arr) c_arr.sort(key=lambda item: item[0]) r_arr = [] c = 0 i = 0 while i <...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING AS...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
n, d = map(int, input().split()) d1, d2 = map(int, input().split()) arr = [0] * n for i in range(n): a, b = map(int, input().split()) arr[i] = [d1 * a + d2 * b, i + 1] arr.sort() res, idx = 0, "" for i in arr: if d - i[0] < 0: break d -= i[0] res += 1 idx += str(i[1]) + " " print(res) pr...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
R = lambda: map(int, input().split()) n, d = R() a, b = R() def get(): x, y = R() return a * x + b * y s = sorted([(get(), i) for i in range(1, n + 1)]) ans = [] for i in range(n): if d >= s[i][0]: ans += [s[i][1]] d -= s[i][0] else: break print(len(ans)) print(*ans)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
n, d = map(int, input().split()) a, b = map(int, input().split()) x = [] for i in range(n): q, w = map(int, input().split()) x.append([q, w, i + 1]) x.sort(key=lambda i: a * i[0] + b * i[1]) z = [] s = 0 for i in range(n): if s + a * x[i][0] + b * x[i][1] <= d: s = s + a * x[i][0] + b * x[i][1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VA...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
R = lambda: map(int, input().rstrip().split()) n, d = R() a, b = R() l = [] for i in range(n): x, y = R() cost = x * a + y * b l.append([i + 1, cost]) l.sort(key=lambda x: x[1]) t = 0 cost = 0 i = 0 while i < n: if cost + l[i][1] <= d: cost += l[i][1] i += 1 t += 1 else: ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER ASSI...
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve. The camera's memory is d megabytes. Valera's camera can take photos of high and l...
n, d = map(int, input().split()) a, b = map(int, input().split()) l = [] for i in range(1, n + 1): a1, b1 = map(int, input().split()) l.append([a1 * a + b1 * b, i]) l.sort() temp = d ans = [] for i in l: if i[0] <= temp: ans.append(i[1]) temp -= i[0] else: break print(len(ans)) p...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR AS...
In the evening Polycarp decided to analyze his today's travel expenses on public transport. The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t...
n, a, b, k, f = [int(i) for i in input().split()] pred = "_" d = dict() for i in range(n): s1, s2 = [i for i in input().split()] pr = a if s1 == pred: pr = b if (s1, s2) in list(d.keys()): d[s1, s2] += pr elif (s2, s1) in list(d.keys()): d[s2, s1] += pr else: d[s1...
ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR FUNC_CALL VAR FUNC_CALL ...
In the evening Polycarp decided to analyze his today's travel expenses on public transport. The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t...
n, a, b, k, f = list(map(int, input().split())) totalCost = {} lastStop = "" total = 0 for i in range(n): s1, s2 = input().split() cost = a if lastStop != s1 else b key = min(s1, s2), max(s1, s2) if key not in totalCost: totalCost[key] = cost else: totalCost[key] += cost total +=...
ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR ...
In the evening Polycarp decided to analyze his today's travel expenses on public transport. The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t...
def main(): trips, reg, cheap, cards, card_cost = list(map(int, input().split())) costs = [] indexes = {} total = 0 last = "" for i in range(trips): a, b = input().split() pair = min(a, b), max(a, b) if pair in indexes: index = indexes[pair] else: ...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_...
In the evening Polycarp decided to analyze his today's travel expenses on public transport. The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t...
n, a, b, k, f = [int(i) for i in input().split()] stops = dict() prev = "" ans = 0 for i in range(n): x, y = [i for i in input().split()] price = a if x == prev: price = b prev = y p, q = min(x, y), max(x, y) if (p, q) in stops: stops[p, q] += price else: stops[p, q] ...
ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VA...
In the evening Polycarp decided to analyze his today's travel expenses on public transport. The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t...
n, a, b, k, f = map(int, input().split()) slov = dict() temp = input().split() slov[frozenset(temp)] = a for i in range(1, n): temp2 = input().split() try: if temp2[0] == temp[1]: slov[frozenset(temp2)] += b else: slov[frozenset(temp2)] += a except KeyError: i...
ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NU...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) a.sort(key=lambda x: -x) answer = 0 for i in range(n - 2): v = 2 * a[i] - a[i + 1] - a[n - 1] if v > answer: answer = v for j in range(2, n): v = a[0] + a[j - 1] - 2 * a[j...
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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def get_score(one, two, three): return abs(one - two) + abs(two - three) def solution(num_list: list, length: int): num_list.sort() high = 0 for i in range(length - 2): value = num_list[i + 1] - num_list[i] + num_list[-1] - num_list[i] if value > high: high = value for ...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): n = int(input()) a = sorted(list(map(int, input().split()))) sum = 0 for i in range(n - 1): sum = max(sum, abs(a[i + 1] - a[i] + abs(a[i] - a[n - 1]))) for i in range(1, n): sum = max(sum, abs(a[i] - a[i - 1] + a[i] - a[0])) print(sum)
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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBE...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for i in range(t): n = int(input()) arr = [int(i) for i in input().split()] arr.sort() ans = arr[n - 1] - arr[0] for i in range(n - 1): ans = max( ans, arr[n - 1] + arr[i + 1] - 2 * arr[i], 2 * arr[i + 1] - arr[i] - arr[0] ) 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BI...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def bar(A): res = 0 for i in range(1, len(A) - 1): ma = A[i - 1] res = max(res, A[i] - ma + A[-1] - ma) return res def foo(): N = int(input()) A = sorted(list(map(int, input().strip().split()))) B = [(-x) for x in A][::-1] return max(bar(A), bar(B)) T = int(input()) for _...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) while t > 0: n = int(input()) a = [int(x) for x in input().split()] a.sort() ans = 0 for i in range(1, n - 1): ans = max(ans, a[i] - a[i - 1] + a[-1] - a[i - 1]) for i in range(1, n - 1): ans = max(ans, a[-i] - a[-1 - i] + a[-i] - a[0]) print(ans) 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
T = int(input()) for _ in range(T): n = int(input()) a = list(map(int, input().split())) a.sort() b = [2 * a[-1] - a[0] - a[-2], a[-1] + a[1] - 2 * a[0]] for i in range(1, n - 1): b.append(max(a[i] - a[0] + a[i] - a[i - 1], a[-1] - a[i] + a[i + 1] - a[i])) print(max(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 ASSIGN VAR LIST BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
case = int(input()) for i in range(case): n = int(input()) mas = list(map(int, input().split())) mas.sort() cur_max = 0 for j in range(1, len(mas) - 1): cur_min = mas[j - 1] cur_max = max(cur_max, mas[-1] - 2 * cur_min + mas[j]) cur_min = mas[len(mas) - j] cur_max = m...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CA...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
T = int(input()) for tt in range(T): n = int(input()) data = list(map(int, input().split())) data = sorted(data) subtract = [] for i in range(1, n): subtract.append(data[i] - data[i - 1]) ans = 0 the_sum = sum(subtract) for i in range(len(subtract) - 1): ans = max(ans, th...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMB...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def main(): t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) a.sort() m_a = min(a) M_a = max(a) init_val = max(M_a - m_a + a[1] - m_a, M_a - m_a + M_a - a[-2]) for i in range(1, n - 1): val1 = M_a - a[i] ...
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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBE...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def solve() -> None: n = int(input()) weights = list(map(int, input().split())) weights.sort() ans = 0 for i in range(2, n): ans = max(ans, weights[i] - weights[i - 1] + weights[i] - weights[0]) for i in range(1, n - 1): ans = max(ans, weights[i] - weights[i - 1] + weights[-1] - ...
FUNC_DEF 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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for i in range(t): n = int(input()) lis = [int(i) for i in input().split()] lis.sort() max = 0 for i in range(2, n): if max < 2 * lis[i] - lis[i - 1] - lis[0]: max = 2 * lis[i] - lis[i - 1] - lis[0] for i in range(n - 1): if max < lis[i + 1] + lis[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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BI...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) a.sort() mnToMx = 0 for i in range(n - 2): mnToMx = max(mnToMx, abs(a[i] - a[i + 1]) + abs(a[i] - a[n - 1])) mxToMn = 0 i = n - 1 while i >= 2: mxToMn = max(mxToMn, abs(a[i] - a[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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR BIN...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) while t > 0: n = int(input()) b = list(map(int, input().split())) b.sort() ans = 0 first = b[0] last = b[-1] for bri in range(2, n): br = b[bri] ans1 = br - first + br - b[bri - 1] if ans1 > ans: ans = ans1 for bri in range(0, n - 2): ...
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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) while t > 0: n = int(input()) a = list(map(int, input().split())) a.sort() ans = abs(a[0] - a[n - 1]) + abs(a[n - 1] - a[n - 2]) ans = max(ans, abs(a[n - 1] - a[0]) + abs(a[0] - a[1])) for i in range(2, n): ans = max(ans, abs(a[0] - a[i]) + abs(a[i] - a[i - 1])) for ...
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 BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER AS...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) ans = 0 a.sort() for i in range(n - 1): ans = max(ans, a[n - 1] + a[i] - 2 * a[i - 1], 2 * a[i + 1] - a[i] - a[0]) print(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 ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): n = int(input()) lst_a = sorted(map(int, input().split())) mx = 0 for j in range(n): mx = max(mx, 2 * lst_a[j] - lst_a[0] - lst_a[j - 1]) for j in range(n - 1): mx = max(mx, lst_a[-1] + lst_a[j + 1] - 2 * lst_a[j]) print(mx)
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 NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
T = int(input()) for kse in range(T): n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(n - 1): ans = max( ans, max(a[i + 1] - a[0] + a[i + 1] - a[i], a[n - 1] - a[i] + a[i + 1] - a[i]), ) 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) arr = sorted(list(map(int, input().split()))) ans = arr[-1] - arr[0] for i in range(n - 1): b1 = arr[i + 1] b2 = arr[-1] b3 = arr[0] ans = max(ans, b1 + b2 - 2 * arr[i], 2 * b1 - arr[i] - b3) print(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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a = sorted(a) mx = a[-1] mn = a[0] a1 = a[0] an_1 = a[-1] for e in a: if e != mn: a1 = e break for i in range(n - 1, -1, -1): if a[i] != mx: an_1 = 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FOR VAR F...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l.sort() res = 0 for i in range(1, n - 1): res = max((res, 2 * l[i + 1] - l[0] - l[i], l[n - 1] + l[i] - 2 * l[i - 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER V...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) l = list(map(int, input().strip().split())) co = 0 l = list(set(l)) l.sort() n = len(l) if n <= 1: co = 0 elif n == 2: co = 2 * (l[1] - l[0]) else: co = l[-1] - l[0] + max(l[...
IMPORT ASSIGN VAR 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VA...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def solve(arr, n): arr.sort() maxx = 0 for i in range(1, n - 1): maxx = max(maxx, abs(arr[i + 1] - arr[0]) + abs(arr[i + 1] - arr[i])) for i in range(0, n - 2): maxx = max(maxx, abs(arr[n - 1] - arr[i]) + abs(arr[i + 1] - arr[i])) print(maxx) for _ in range(int(input())): n = i...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUN...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def sol(lst): res = 0 lst.sort() for i in range(1, n): res = max(res, 2 * lst[i] - lst[i - 1] - lst[0]) for i in reversed(range(len(lst) - 2)): res = max(res, lst[n - 1] + lst[i + 1] - 2 * lst[i]) return res T = int(input()) for test_case in range(1, T + 1): n = int(input()) ...
FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def solve(): n = int(input()) a = list(map(int, input().split())) a.sort() v1 = 0 v2 = 0 for i in range(n - 1, 1, -1): v1 = max(2 * a[i] - a[i - 1] - a[0], v1) for i in range(0, n - 2): v2 = max(a[i + 1] + a[-1] - 2 * a[i], v2) return max(v1, v2) for t in range(0, int(i...
FUNC_DEF 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VA...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() maxx = 0 for j in range(2, n): maxx = max(maxx, abs(a[0] - a[j]) + abs(a[j] - a[j - 1])) for k in range(n - 2): maxx = max(maxx, abs(a[n - 1] - a[k]) + abs(a[k] - a[k + 1])) print(maxx...
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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
casecnt = int(input()) for case in range(casecnt): n = int(input()) a = [int(i) for i in input().split()] a.sort() bestscore = 0 for i in range(1, n): g = a[i] - a[i - 1] score = g score += max(a[i] - a[0], a[n - 1] - a[i - 1]) bestscore = max(score, bestscore) pr...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP V...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def N(): return int(input()) def A(): return [int(x) for x in input().split()] def S(): return input() for _ in range(N()): n = N() if "codeforces" == 28226329: print("Tanmay") a = A() a.sort() ans = 0 for i in range(n - 1): ans = max(ans, abs(a[i + 1] - a[i]) +...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
import sys def read(): return [int(x) for x in sys.stdin.readline().split(" ")] [t] = read() for _ in range(t): [n] = read() A = read() A.sort() res = A[n - 1] - A[0] for i in range(1, n - 1): res = max(res, 2 * A[i + 1] - A[i] - A[0]) for i in range(0, n - 2): res = max(...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN LIST VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) mx = -1 l = list(map(int, input().split())) l.sort() for i in range(n - 1): mx = max(mx, l[-1] - l[i] + l[i + 1] - l[i]) mx = max(mx, abs(l[i + 1] - l[i]) + abs(l[i + 1] - l[0])) print(mx)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUM...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def brick(): t = int(input()) for i in range(t): n = int(input()) para = input().split(" ") bri = [int(x) for x in para] bri.sort() s, l = bri[0], bri[-1] e1 = l - s + max(min(bri[1:-1]) - s, l - max(bri[1:-1])) for i in range(1, len(bri) - 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 FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) l.sort() maxi = 0 for i in range(0, len(l) - 2): ans1 = abs(l[i] - l[-1]) + abs(l[-1] - l[-2]) ans2 = abs(l[-1] - l[i]) + abs(l[i] - l[i + 1]) maxi = max(maxi, ans1, ans2) l.sort(reve...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR ...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l = sorted(l) ans = 0 for i in range(1, n - 1): ans = max(ans, l[i] - l[i - 1] + l[-1] - l[i - 1]) l = l[::-1] for i in range(1, n - 1): ans = max(ans, l[i - 1] - l[i] + l[i - 1] - l[-1]) p...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP V...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for j in range(0, t): n = int(input()) l = list(map(int, input().split())) l.sort() s = 0 for k in range(0, n): if k == 0: s = max(s, abs(l[k] - l[n - 1]) + abs(l[k] - l[1])) elif k == n - 1: s = max(s, abs(l[k] - l[0]) + abs(l[n - 2] - l[k]))...
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP V...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def f(arr): s_arr = sorted(arr) res = 0 for i in range(len(arr) - 2): res = max([res, s_arr[i + 1] - s_arr[i] + s_arr[-1] - s_arr[i]]) for i in range(len(arr) - 1, 1, -1): res = max([res, s_arr[i] - s_arr[i - 1] + s_arr[i] - s_arr[0]]) return res t = int(input()) for i in range(t):...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR LIST VAR BIN_...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(n): if i < n - 2: res = A[i + 1] - A[i] + A[n - 1] - A[i] ans = max(ans, res) if i >= 2: res = A[i] - A[i - 1] + A[i] - A[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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input("")) for j in range(t): n = int(input("")) l = list(map(int, input("").split())) l.sort() m = 0 for i in range(-1, -len(l) + 1, -1): a = l[i] + l[i] - l[i - 1] - l[0] if m < a: m = a for i in range(0, n - 2): a = l[-1] + l[i + 1] - l[i] - l[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_O...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
def sol(lst): lst.sort() maxi = 0 for i in range(2, len(lst)): maxi = max(maxi, abs(lst[i] - lst[i - 1]) + abs(lst[i] - lst[0])) for i in reversed(range(len(lst) - 2)): maxi = max(maxi, abs(lst[i] - lst[i + 1]) + abs(lst[i] - lst[-1])) return maxi T = int(input()) for test_case in ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): n = int(input()) w = list(map(int, input().split(" "))) w1 = sorted(w) w2 = sorted(w, reverse=True) answer = 0 for i in range(n - 2): answer = max( answer, abs(w1[i] - w1[i + 1]) + abs(w1[i] - w1[n - 1]), abs(w2[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 STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CAL...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for t1 in range(t): n = int(input()) a = sorted(list(map(int, input().split()))) ans = 0 for i in range(n - 1): mx = a[i + 1] - a[i] + max(a[i + 1] - a[0], a[-1] - a[i]) if mx > ans: ans = mx 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP V...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for _ in range(t): input() temp = input().split() l = [int(v) for v in temp] l.sort() largest = 0 for b in range(0, len(l) - 2): m = abs(l[b] - l[b + 1]) + abs(l[b] - l[-1]) if m > largest: largest = m l.reverse() for b in range(0, len(l) - 2)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMB...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
for T in range(int(input())): n = int(input()) a = sorted(list(map(int, input().split()))) ans = a[n - 1] - a[0] for i in range(2, n): ans = max(ans, a[i] - a[0] + a[i] - a[i - 1]) for i in range(0, n - 1): ans = max(ans, a[i + 1] - a[i] + a[n - 1] - a[i]) ans = max(ans, a[n - 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMB...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) out = [] def solve(arr): arr = sorted(arr) max1 = abs(arr[-1] - arr[-2]) + abs(arr[-1] - arr[0]) for i in range(len(arr) - 2, 1, -1): temp = abs(arr[i] - arr[i - 1]) + abs(arr[i] - arr[0]) if temp > max1: max1 = temp max2 = abs(arr[-1] - arr[-3]) + abs(arr[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_...
There are $n$ bricks numbered from $1$ to $n$. Brick $i$ has a weight of $a_i$. Pak Chanek has $3$ bags numbered from $1$ to $3$ that are initially empty. For each brick, Pak Chanek must put it into one of the bags. After this, each bag must contain at least one brick. After Pak Chanek distributes the bricks, Bu Deng...
t = int(input()) for j in range(t): n = int(input()) a = [int(x) for x in input().split()] a.sort() max = a[n - 1] - a[0] for i in range(0, len(a) - 1): if max < a[n - 1] - a[i] + a[i + 1] - a[i]: max = a[n - 1] - a[i] + a[i + 1] - a[i] for i in range(len(a) - 1, 0, -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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP BIN_OP ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
inp = [int(x) for x in input().split()] n, m = inp[:2] k = inp[-1] l = [int(x) for x in input().split()] arr = [[i, j] for i, j in enumerate(l)] arr = sorted(arr, key=lambda x: x[1], reverse=True) summ = 0 for i in range(m * k): summ += arr[i][1] print(summ) rs = [(i[0] + 1) for i in arr[: m * k]] rs.sort() frs = [...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
[n, m, k] = list(map(int, input().split())) a = list(map(int, input().split())) b = a[:] b.sort(reverse=True) can = b[m * k - 1] last = 0 for i in range(m * k, len(b)): if b[i] == can: last += 1 else: break ans = 0 for i in range(m * k): ans += b[i] print(ans) num = 0 ans = [] for i in range...
ASSIGN LIST VAR VAR 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 VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) ind = list(sorted(range(n), key=lambda i: a[i], reverse=True)) ind2 = list(sorted(ind[: m * k])) print(sum(a[i] for i in ind2)) for i in range(k - 1): print(ind2[i * m + m - 1] + 1, end=" ") print()
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def rli(): return list(map(int, input().split())) def main(): n, m, k = rli() nums = rli() x = [] for i in range(len(nums)): x.append((nums[i], i)) choosed = [0] * len(nums) tot = 0 x.sort() x = x[-1::-1] for i in range(m * k): tot += x[i][0] choosed[x[i...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
l = list(map(int, input().split())) a = list(map(int, input().split())) b = a[:] b.sort(reverse=True) minn = b[l[2] * l[1] - 1] cnt = 0 summ = 0 for i in range(l[2] * l[1]): summ = summ + b[i] if b[i] > minn: cnt = cnt + 1 minn_cnt = l[2] * l[1] - cnt y = l[2] - 1 lenn = 0 i = 0 index = [] while y > 0: ...
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 VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = list(zip(range(n), map(int, input().split()))) arr.sort(key=lambda x: x[1], reverse=True) arr = arr[: m * k] arr.sort(key=lambda x: x[0]) ans = [] for i in range(m, m * k, m): ans.append(arr[i][0]) print(sum([x[1] for x in arr])) print(*ans)
ASSIGN VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR EX...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
import sys n, m, k = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) arr = [] for i in range(n): arr.append([a[i], i]) arr.sort(reverse=True) index = [] ans = 0 for i in range(m * k): ans += arr[i][0] index.append(arr[i][1]) index.sort() print(ans) ans1 = [] for i in...
IMPORT ASSIGN 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
list_int_input = lambda inp: list(map(int, inp.split())) int_input = lambda inp: int(inp) string_to_list_input = lambda inp: list(inp) n, m, k = map(int, input().split()) a = list_int_input(input()) a = [(ind, val) for ind, val in enumerate(a)] a.sort(key=lambda x: x[1]) a = a[n - m * k :] a.sort(key=lambda x: x[0]) su...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) r = list(map(int, input().split())) r = [[r[i], i] for i in range(n)] r.sort(reverse=True) ans = 0 ind = [0] * (m * k) for i in range(m * k): ans += r[i][0] ind[i] = r[i][1] ind.sort() print(ans) for i in range(k - 1): print(ind[(i + 1) * m - 1] + 1, end=" ")
ASSIGN 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 ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMB...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
l = input().split() n = int(l[0]) m = int(l[1]) k = int(l[2]) l = input().split() li = [int(i) for i in l] lfi = [] for i in range(n): lfi.append((int(l[i]), i)) lfi.sort() lfi.reverse() hashi = dict() summax = 0 for i in range(m * k): summax += lfi[i][0] hashi[lfi[i][1]] = 1 lpart = [] tillnow = 0 for i in...
ASSIGN VAR 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = sorted(a, reverse=True) d = dict() s = 0 for i in b[: m * k]: s += i if i in d: d[i] += 1 else: d[i] = 1 ans = [] prev = 0 for i in range(k - 1): count = 0 pos = prev while count < m: if a[pos] in...
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUM...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) lis = list(map(int, input().split())) aa = sorted(range(len(lis)), key=lambda k: lis[k], reverse=True) t = m * k aa = aa[:t] aa.sort() p = 0 for i in aa: p += lis[i] ans = [] i = m while i < len(aa): ans.append(aa[i - 1] + 1) i += m print(p) print(*ans)
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR ASSIGN VAR LIS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr1 = list(map(int, input().split())) arr2 = [] for i in range(len(arr1)): arr2.append((arr1[i], i)) arr2.sort(reverse=True) arr3 = [] ans = 0 for i in range(m * k): ans += arr2[i][0] arr3.append(arr2[i][1]) arr3.sort() ansarr = [] count = 0 for i in range(m * k - m): ...
ASSIGN 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] tot = [] i = 0 counter = 0 total = [] for item in a: tot.append((item, i)) i += 1 tot.sort(reverse=True) for i in range(m * k): total.append(tot[i][1]) counter += tot[i][0] total.sort() answer = [] for i in range(m, len(to...
ASSIGN VAR VAR 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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(i) for i in input().split()] arr = [int(i) for i in input().split()] arr = [(arr[i], i) for i in range(n)] arr.sort(reverse=True) lis = [] ans = 0 for i in range(m * k): ans += arr[i][0] lis.append(arr[i][1]) lis.sort() a1 = [] for i in range(m - 1, len(lis), m): a1.append(lis[i] + 1) print(a...
ASSIGN VAR VAR 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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXP...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = list(map(int, input().split())) c = [i for i in range(n)] c.sort(key=lambda x: arr[x]) res = c[n - m * k :] res.sort() total = 0 for i in res: total += arr[i] print(total) for i in range(m - 1, len(res) - 1, m): print(res[i] + 1, end=" ")
ASSIGN 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 ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) vec = list(map(int, input().split())) must = [] for i in range(n): must.append([vec[i], i]) must.sort(reverse=True) mustLen = m * k ans = 0 spl = [0] * (n + 1) for i in range(0, mustLen): spl[must[i][1]] = 1 ans += must[i][0] cur = 0 print(ans) for i in range(n): cur ...
ASSIGN 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUM...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def find_lower_bound(array, n, m, k): tmp_array = sorted(array, reverse=1) cnt = 0 for i in range(n): if tmp_array[i] > tmp_array[m * k - 1]: cnt += 1 else: break return [tmp_array[m * k - 1], m * k - cnt] def find_beauty(array, upper_bound, lower_bound, m): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER RETURN LIST VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR RETU...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) ar = list(map(int, input().split())) pos = [] for i in range(n): pos.append([i, ar[i]]) st = sorted(pos, key=lambda a: a[1], reverse=True) s = 0 for i in range(m * k): s += st[i][1] print(s) req = st[: m * k] req.sort(key=lambda a: a[0]) ct = 0 z = 0 for i in range(0, m * k, ...
ASSIGN 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
_ = input() n, m, k = _.split() n, m, k = int(n), int(m), int(k) _ = input() a = _.split() a = [(i, int(value)) for i, value in enumerate(a)] position = [] b = sorted(a, key=lambda p: p[1]) b = b[-m * k :] answer = 0 for i in b: answer = answer + i[1] print(answer) answer = "" position = [(p[0] + 1) for p in b] pos...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def answer(n, m, k, A): count = 0 l = sorted(A) maxi = 0 d = {} for i in range(n - 1, -1, -1): if count == m * k: break if l[i] in d: d[l[i]] += 1 else: d[l[i]] = 1 maxi += l[i] count += 1 ans = [] count = 0 for ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
[n, m, k] = [int(x) for x in input().split()] a = [int(x) for x in input().split()] sort = sorted(a) sort.reverse() comparison = sort[m * k - 1] num_comparison = sort[: m * k].count(comparison) partition_count = 0 output = [] curr_k = k for i in range(n): if a[i] > comparison or a[i] == comparison and num_compariso...
ASSIGN LIST VAR VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def main(): arr = input().split() n = int(arr[0]) m = int(arr[1]) k = int(arr[2]) arr = input().split() store = [] for x in range(n): arr[x] = int(arr[x]) store.append(arr[x]) store.sort() bound = store[-(m * k)] count = 0 total = 0 for x in range(-(m * k)...
FUNC_DEF ASSIGN VAR 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(s) for s in input().split(" ")] array = [int(s) for s in input().split(" ")] index = sorted(range(len(array)), key=lambda k: array[k], reverse=True) index = sorted(index[: m * k]) out = index[m - 1 :: m][:-1] print(sum(array[i] for i in index)) print(" ".join(str(i + 1) for i in out))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) l = [int(i) for i in input().split()] z = m * k l1 = [[l[i], i] for i in range(n)] l1.sort(key=lambda x: -x[0]) req = [] sm = 0 for i in range(z): req.append(l1[i][1]) sm += l1[i][0] req.sort() print(sm) cnt = 0 for i in range(len(req)): cnt += 1 if cnt % m == 0 and i...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [] for i in range(n): b.append([a[i], i]) def sortFirst(val): return val[0] b.sort(key=sortFirst, reverse=True) jog = 0 ind = [] for i in range(m * k): jog += b[i][0] ind.append(b[i][1] + 1) ind.sort() l = m - 1 ans = [ind[l...
ASSIGN 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR B...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split(" "))) std_in = list(map(int, input().split(" "))) a = [(std_in[i], i) for i in range(n)] a = sorted(a, key=lambda x: x[0], reverse=True) largest = a[: m * k] print(sum([i[0] for i in largest])) ind = sorted(largest, key=lambda x: x[1]) print(" ".join([str(ind[m * i - 1][1] + 1) fo...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBE...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) indexed_a = zip(a, list(range(n))) sorted_indexed_a = list(reversed(sorted(indexed_a))) sorted_a = list(reversed(sorted(a))) partition = list(sorted([y for x, y in sorted_indexed_a[: m * k]])) print(sum(sorted_a[: m * k])) result = [(x + 1) f...
ASSIGN VAR VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) x = sorted(a, reverse=True) d = {} for i in range(m * k): if x[i] in d: d[x[i]] += 1 else: d[x[i]] = 1 indx = [] c = 0 for i in range(n): if a[i] in d: c += 1 d[a[i]] -= 1 if d[a[i]] == 0: ...
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [] b.sort() mn = 10**18 q = 0 for i in range(n): b.append([a[i], i]) b.sort(reverse=True) l = 0 ind = [] for i in range(m * k): q += b[i][0] ind.append(b[i][1]) ind.sort() ans = [] for i in range(len(ind)): l += 1 if l % m =...
ASSIGN 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 ASSIGN VAR LIST EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER A...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
from sys import stdin, stdout n, m, k = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] I = list(reversed(sorted(range(n), key=lambda i: A[i]))) S = set(I[: m * k]) ans = [] count = 0 for i in range(n): if i in S: count += 1 if count == m: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
[n, m, k] = list(map(int, input().split())) a = list(map(int, input().split())) b = list(a) b.sort(reverse=True) pool = dict() val = 0 for i in range(m * k): if b[i] in pool: pool[b[i]] += 1 else: pool[b[i]] = 1 val += b[i] res = list() hit = 0 for i in range(n): if a[i] in pool and pool...
ASSIGN LIST VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSI...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = a[:] b.sort(reverse=True) s = 0 c = {} for i in range(m * k): s += b[i] c[b[i]] = c.get(b[i], 0) + 1 print(s) ans = [] ms = m for i in range(n): if c.get(a[i], 0) > 0: c[a[i]] -= 1 ms -= 1 if ms == 0: ...
ASSIGN 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 ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def make_string(ans): sss = "" for index, value in enumerate(ans): if index: sss += " " sss += str(value) return sss def each(): n, m, k = [int(x) for x in input().split(" ")] arr = [[int(value), index] for index, value in enumerate(input().split(" "))] arr.sort() ...
FUNC_DEF ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = sorted(range(len(a)), key=lambda i: a[i], reverse=True) b = b[: m * k] b.sort() sum = 0 for i in b: sum += a[i] print(sum) b = b[m - 1 : -1 : m] for i in b: print(i + 1, end=" ") print()
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) p = [(0, 0)] * n for i in range(n): p[i] = i, a[i] s = sorted(p, key=lambda g: g[1], reverse=True) s = s[: k * m] s = sorted(s, key=lambda g: g[0]) h = 0 for i in range(len(s)): h += s[i][1] print(h) l = [] for i in range(1, k): l...
ASSIGN VAR VAR 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 LIST NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
R = lambda: map(int, input().split()) n, m, k = R() a, b = zip(*sorted(zip(R(), range(1, n + 1)))[-m * k :]) print(sum(a), *sorted(b)[m - 1 : -1 : m])
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = (int(t) for t in input().split(" ")) a = [int(t) for t in input().split(" ")] s = list(enumerate(a)) s.sort(key=lambda x: x[1], reverse=True) s = s[: m * k] print(sum(x[1] for x in s)) s = [x[0] for x in s] s.sort() print(*[(s[i - 1] + 1) for i in range(m, m * k, m)])
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) x = sorted(sorted(range(1, n + 1), key=lambda i: a[i - 1], reverse=True)[: m * k]) print(sum(a[i - 1] for i in x)) print(*x[m - 1 : -1 : m])
ASSIGN 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FU...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) check = [False] * n res = 0 for i in range(n): a[i] = a[i], i a.sort(reverse=True) for i in range(m * k): check[a[i][1]] = True res += a[i][0] print(res) ht = 0 for i in range(n): if check[i]: ht += 1 if ht == m: ...
ASSIGN 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBE...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
read = lambda: map(int, input().split()) def takeFirst(element): return element[0] def takeSecond(element): return element[1] n, m, k = read() a = list(read()) b = [] for cnt, x in enumerate(a): b.append([cnt, x]) b.sort(key=takeSecond, reverse=True) b = b[: m * k] b.sort(key=takeFirst) print(sum([x[1...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN VAR NUMBER FUNC_DEF RETURN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXP...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def func(n): return n[1] n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [[a[i], i] for i in range(len(a))] b.sort(reverse=True) b = b[: m * k] b.sort(key=func) ans = [] ans2 = 0 for i in range(0, len(b), 1): if (i + 1) % m == 0: ans.append(b[i][1] + 1) ans2 += b[i][0] ...
FUNC_DEF RETURN VAR NUMBER ASSIGN 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 ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = sorted( [(el[1], el[0]) for el in enumerate(map(int, input().split()))], reverse=True ) value = 0 ind = [0] * (m * k) for i in range(m * k): value += a[i][0] ind[i] = a[i][1] ind.sort() print(value) for i in range(m, m * k, m): print(ind[i - 1] + 1, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUM...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) arr = list(map(int, input().split())) brr = [] for i in arr: brr.append(i) arr.sort(reverse=True) suma = 0 dic = {} for i in arr: dic[i] = 0 for i in range(m * k): suma += arr[i] dic[arr[i]] += 1 ans = [] count = 0 counta = 0 for i in range(len(arr)): if cou...
ASSIGN VAR VAR 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 LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR ...