description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
There are $n$ people in a row. The height of the $i$-th person is $a_i$. You can choose any subset of these people and try to arrange them into a balanced circle. A balanced circle is such an order of people that the difference between heights of any adjacent people is no more than $1$. For example, let heights of cho...
rint = lambda: int(input()) rmint = lambda: map(int, input().split()) rlist = lambda: list(rmint()) n = rint() lst = rlist() cnt = {} for nb in lst: if nb not in cnt: cnt[nb] = 1 else: cnt[nb] += 1 arr = sorted(list(cnt.keys())) N = len(arr) left, right, k = 0, 0, cnt[arr[0]] left_best, right_be...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR...
There are $n$ people in a row. The height of the $i$-th person is $a_i$. You can choose any subset of these people and try to arrange them into a balanced circle. A balanced circle is such an order of people that the difference between heights of any adjacent people is no more than $1$. For example, let heights of cho...
n = int(input()) a = list(map(int, input().split())) cnt = [0] * 200005 for i in range(0, n): cnt[a[i]] += 1 ans = 0 ansl = 0 ansr = 0 l = 1 N = 200001 while l <= N: if cnt[l] == 0: l += 1 else: r = l now = 0 while r <= N: if cnt[r] == 0: r -= 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR...
There are $n$ people in a row. The height of the $i$-th person is $a_i$. You can choose any subset of these people and try to arrange them into a balanced circle. A balanced circle is such an order of people that the difference between heights of any adjacent people is no more than $1$. For example, let heights of cho...
n = int(input()) a = [int(x) for x in input().split()] if n == 1: print(1) print(a[0]) return a.sort() b = [a[0]] cnt = [0] * (200 * 1000 + 1) cnt[a[0]] += 1 for i in range(1, n): cnt[a[i]] += 1 if a[i - 1] != a[i]: b.append(a[i]) l = 0 r = 1 ans = cnt[a[0]] i = 0 while i < len(b): j = i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER RETURN EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_C...
You are given a sequence $a_1, a_2, \dots, a_n$, consisting of integers. You can apply the following operation to this sequence: choose some integer $x$ and move all elements equal to $x$ either to the beginning, or to the end of $a$. Note that you have to move all these elements in one direction in one operation. Fo...
import sys input = sys.stdin.readline def solve(): n = int(input()) a = list(map(int, input().split())) s = set(a) s = sorted(list(s)) ref = {x: i for i, x in enumerate(list(s))} sz = len(s) L = [1 << 32] * sz R = [-1 << 32] * sz for i in range(n): k = ref[a[i]] L[...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST ...
You are given $n$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$. The following operation can be applied: Select three elements $i$, $j$ and $k$ ($1 \leq i < j < k \leq n$), such that $c_i$, $c_j$ and $c_k$ are all equal to $0$ and $a_i = a_k$, the...
n = int(input()) a = [int(i) for i in input().split()] last = {x: i for i, x in enumerate(a)} lastest, covered, ans = 0, 0, 0 for i, x in enumerate(a): lastest = max(lastest, last[x]) if covered > i: ans += 1 else: covered = lastest print(ans)
ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
n = int(input()) xs = [(int(a) - 1) for a in input().split()] ys = [(int(a) - 1) for a in input().split()] def invert(xs): ret = [0] * len(xs) for i, x in enumerate(xs): ret[x] = i return ret xs = invert(xs) ys = invert(ys) intervals = [(min(x, y), max(x, y)) for x, y in zip(xs, ys)] i, j = inte...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL V...
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
n = int(input()) p = [int(x) for x in input().split(" ")] q = [int(x) for x in input().split(" ")] dicp = {} dicq = {} for i in range(n): dicp[p[i]] = i dicq[q[i]] = i ans = 0 for i in range(1, n + 1): if i == 1: left = min(dicp[i], dicq[i]) right = max(dicp[i], dicq[i]) ans += left ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BI...
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
def f(l, r, x1, x2, n): if x2 < l: return (l - x2) * (n - r) elif x1 > r: return (l + 1) * (x1 - r) elif x1 < l and x2 > r: return (l - x1) * (x2 - r) return 0 def f1(l): res = l * (l + 1) // 2 return res def solve(p, q): n = len(p) p_pos = [0] * n q_pos =...
FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
from sys import stderr def main(p, q) -> int: result = 1 n = len(p) p_inds = {v: i for i, v in enumerate(p)} q_inds = {v: i for i, v in enumerate(q)} one1, one2 = sorted((p_inds[1], q_inds[1])) a = one1 b = one2 - one1 - 1 c = n - one2 - 1 result += a * (a + 1) // 2 + b * (b + 1) /...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN...
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] first, last = [n - 1] * (n + 1), [0] * (n + 1) for j, v in enumerate(a): first[v] = min(first[v], j) last[v] = max(last[v], j) for j, v in enumerate(b): first[v] = min(first[v], j) last[v] = max(last[v], j) firs...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ...
In winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation $p$ of length $n$ to the zoo. A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in any order. For example, $[2,3,1,5,4]$ is...
import sys def solve(): inp = sys.stdin.readline n = int(inp()) p = list(map(int, inp().split())) q = list(map(int, inp().split())) pi = [None] * (n + 1) qi = [None] * (n + 1) for i in range(n): pi[p[i]] = i qi[q[i]] = i x = pi[1] y = qi[1] if x > y: x, ...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from sys import stdin input = stdin.buffer.readline n, d, m = map(int, input().split()) (*a,) = map(int, input().split()) a.sort() c = sum(i <= m for i in a) pref = [a[c - 1]] ans = 0 tmp = 0 for i in range(c - 2, -1, -1): pref.append(pref[-1] + a[i]) for k in range(1, n + 1): tmp += a[n - k] b = (k - 1) *...
ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR LIST VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXP...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys sys.setrecursionlimit(10**5) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def mi(): return map(int, input().split()) def ii(): return int(input()) def li(): return list(map(int, input().split())) def si(): return input().split() n, d, m = mi() a = li() a_s = [] a_b = [] for i in range(n): if a[i] > m: a_b.append(a[i]) else: a_s.append(a[i]) a_b...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CAL...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate n, d, m = map(int, input().split()) A = list(map(int, input().split())) L = [] U = [] for a in A: if a <= m: L.append(a) else: U.append(a) L.sort(reverse=True) U.sort(reverse=True) if len(U) <= 1: print(sum(A)) exit() CL = [0] + L CL = list(accumulate(CL...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_C...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) ar = list(map(int, input().split())) n1, n2 = [(0) for i in range(d)], [] for i in range(n): if ar[i] > m: n2.append(ar[i]) else: n1.append(ar[i]) n1.sort() n2.sort() out = su = sum(n1) n1.sort() n2.sort() j = 0 for i in range(len(n2) - 1, -1, -1): while j...
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 NUMBER VAR FUNC_CALL VAR VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) small, big = [], [] for i in a: if i > m: big.append(i) else: small.append(i) small.sort(reverse=True) big.sort(reverse=True) res = 0 if len(small) == 0: cnt = int((n + d) / (d + 1)) for i in range(cnt): res ...
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 LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = list(map(int, input().split())) arr = list(map(int, input().split())) arr.sort() sm, bg = [], [] for i in range(n): if arr[i] > m: bg.append(arr[i]) else: sm.append(arr[i]) bg.sort() sm.sort() bg.append(0) sm.append(0) bg = bg[-1::-1] sm = sm[-1::-1] ans = -(10**18) for i in range(1, 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR E...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate n, d, m = map(int, input().split()) a = list(map(int, input().split())) lo = [] hi = [] for x in a: if x <= m: lo.append(x) else: hi.append(x) lo.sort(reverse=True) lo_accum = list(accumulate(lo)) hi.sort(reverse=True) hi_accum = list(accumulate(hi)) best = 0 if...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUM...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate n, d, m = map(int, input().split()) a = list(map(int, input().split())) u, v = [], [] for i in a: if i > m: u.append(i) else: v.append(i) u.sort(reverse=True) v.sort(reverse=True) u = list(accumulate(u)) v = list(accumulate(v)) ans = 0 for i in range(0, len(u) +...
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 LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def to_int(s): return int(s) ndm = list(map(to_int, input().split(" "))) n = ndm[0] d = ndm[1] m = ndm[2] values = list(map(to_int, input().split(" "))) good = [] bad = [] for v in values: if v <= m: good.append(v) else: bad.append(v) good.sort(reverse=True) bad.sort(reverse=True) goodSums...
FUNC_DEF RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = [int(inp) for inp in input().split()] aArr = sorted([int(inp) for inp in input().split()], reverse=True) i = sum([(j > m) for j in aArr]) aU = aArr[:i] aL = aArr[i:] aUS = aU for i in range(1, len(aU)): aUS[i] += aUS[i - 1] aUS = [0] + aUS aLS = aL for i in range(1, len(aL)): aLS[i] += aLS[i - 1] aLS ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
t = 1 for test in range(t): n, d, m = map(int, input().split()) arr = list(map(int, input().split())) big = [each for each in arr if each > m] small = [each for each in arr if each <= m] big = [0] + sorted(big, reverse=True) small = [0] + sorted(small, reverse=True) for i in range(1, len(big...
ASSIGN VAR NUMBER FOR 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER F...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.buffer.readline def solution(): n, d, m = map(int, input().split()) a = list(map(int, input().split())) g = [] l = [] for i in range(n): if a[i] > m: g.append(a[i]) else: l.append(a[i]) g.sort(reverse=True) l.sort(revers...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUN...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = tuple(map(int, input().split())) arr = sorted(list(map(int, input().split())), reverse=True) good, bad = [], [] for i in arr: if i <= m: good.append(i) else: bad.append(i) good_pref = [0] for i in range(len(good)): good_pref.append(good_pref[i] + good[i]) bad_pref = [0] for i in ra...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate n, d, m = map(int, input().split()) (*a,) = map(int, input().split()) l, r = [], [] a.sort() a.reverse() for i in range(n): if a[i] <= m: l.append(a[i]) else: r.append(a[i]) rs = [0] + list(accumulate(r)) ls = [0] + list(accumulate(l)) ans = 0 for i in range(len...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) (*arr,) = map(int, input().split()) arr.sort() big = sum(1 for v in arr if v > m) n_large_slots = (n + d) // (d + 1) large = [] small = [] while arr: v = arr.pop() if v > m: large.append(v) else: small.append(v) small_sum = sum(small) nsmall = len(small) s...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) e, f = [i for i in a if i <= m], [i for i in a if i > m] e.sort(reverse=True) f.sort(reverse=True) c = len(e) if c == n: print(sum(a)) exit() l = 1 r = min((n - 1) // (d + 1) + 1, len(f)) ans = sum(e) nowe, nowf = 0, 0 for i in range(l, r +...
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 VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUN...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys readline = sys.stdin.readline N, D, M = map(int, readline().split()) A = list(map(int, readline().split())) Am = [a for a in A if a > M] Ao = [a for a in A if a <= M] Am.sort(reverse=True) Ao.sort(reverse=True) Cam = Am[:] Cao = Ao[:] for i in range(1, len(Cam)): Cam[i] += Cam[i - 1] for i in range(1, l...
IMPORT ASSIGN VAR VAR 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 VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMB...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def solve(): input_str = input().split() n, d, m = int(input_str[0]), int(input_str[1]), int(input_str[2]) a = [0] + [int(x) for x in input().split()] a[1:] = sorted(a[1:], reverse=True) muzzle_days_cnt = 0 for i in range(1, n + 1): if a[i] > m: muzzle_days_cnt += 1 a...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = map(int, input().split()) a = list(map(int, input().split())) b = [] c = [] for e in a: if e > m: b.append(e) else: c.append(e) b.sort(reverse=True) c.sort(reverse=True) bb = [] cc = [] tmp = 0 for e in b: tmp += e bb.append(tmp) tmp = 0 f...
IMPORT ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST A...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def solve(n, d, m, a): a.sort() small = sorted(x for x in a if x <= m) scs = [0] for x in small: scs.append(scs[-1] + x) sol = scs[-1] bn = n - len(small) take, r, sbig, possible = 1, n - 1, 0, True while possible: skip = d * (take - 1) if a[r] > m and skip + take...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMB...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) s = [int(x) for x in input().split()] L1 = [] L2 = [] for i in range(0, len(s)): if s[i] <= m: L2.append(s[i]) else: L1.append(s[i]) L1.sort() L1 = L1[::-1] L2.sort() ans = 0 tt1 = len(L1) // (d + 1) if len(L1) % (d + 1) != 0: tt1 += 1 for i in range(tt1):...
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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CAL...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline N, D, M = map(int, input().split()) X = list(map(int, input().split())) Y, Z = [], [] for i in range(N): if X[i] > M: Y.append(X[i]) else: Z.append(X[i]) X.sort() Y.sort() Z.sort() X = X[::-1] Y = Y[::-1] Z = Z[::-1] zs = 0 yk = -(-N // (D + 1)) ys = sum(Y[...
IMPORT ASSIGN VAR VAR 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 LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [([c] * b) for i in range(a)] def list3d(a, b, c, d): return [[([d] * c) for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[([e] * d) for j in range(c)...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate def main(): n, d, m = map(int, input().split()) A = list(map(int, input().split())) A_low = [] A_high = [] for a in A: if a <= m: A_low.append(a) else: A_high.append(a) Ll = len(A_low) Lh = len(A_high) A_low.sort(...
FUNC_DEF 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBE...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = [*map(int, input().split())] s, b = [], [] for i in a: if i <= m: s.append(i) else: b.append(i) ans = 0 s.sort(reverse=True) b.sort(reverse=True) for i in range(1, len(s)): s[i] += s[i - 1] for i in range(1, len(b)): b[i] += b[i - 1] if len(b) == 0...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CAL...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys readline = sys.stdin.buffer.readline ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) def solve(): n, d, m = nm() a = nl() f = list() g = list() for x in a: if x > m:...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 FUNC_CALL VAR AS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = list(map(int, input().split())) a = list(map(int, input().split())) if max(a) <= m: print(sum(a)) exit() a.sort() k = 0 s = 0 while k < n and a[k] <= m: s += a[k] k += 1 j = 0 p = 0 while n - 1 - j >= 0 and p + k < n: s += a[n - 1 - j] j += 1 p += d + 1 best = s f = 0 p = p + 1 whi...
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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys n, d, m = list(map(int, sys.stdin.readline().strip().split())) a = list(map(int, sys.stdin.readline().strip().split())) a.sort() s1 = 0 s2 = 0 j = 0 i = 0 while a[i] <= m: s1 = s1 + a[i] i = i + 1 if i == n: break b = a[0:i] b.reverse() a = b + a[i:] while j * (d + 1) + i < n: s2 = s...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR B...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
N, D, M = map(int, input().split()) A = sorted(map(int, input().split()), reverse=True) L = [a for a in A if a > M] S = [a for a in A if a <= M] cum_S = [0] c = 0 for s in S: c += s cum_S.append(c) d = N - 1 ans = max(A) if len(L) == 0: print(sum(S)) exit() cum_L = 0 for n, l in enumerate(L, 1): cum...
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 NUMBER ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() cnt = 0 lt = [x for x in arr if x <= m][::-1] gt = [x for x in arr if x > m][::-1] if not gt: print(sum(arr)) exit(0) for i in range(1, len(gt)): gt[i] += gt[i - 1] for i in range(1, len(lt)): lt[i] += lt[i - 1] k = (n ...
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR F...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a = list(reversed(sorted(a))) nl = [x for x in a if x <= m] ml = [x for x in a if x > m] aml = [0] for x in ml: aml.append(aml[-1] + x) anl = [0] for x in nl: anl.append(anl[-1] + x) if len(ml) == 0: print(sum(nl)) return ...
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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def sol(num_days, pause, m, jokes): nbjokes = [] bjokes = [] for joke in jokes: if joke > m: bjokes.append(joke) else: nbjokes.append(joke) bjokes.sort(reverse=True) nbjokes.sort(reverse=True) nb_prefix = [0] for nb in nbjokes: nb_prefix.append...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def gns(): return list(map(int, input().split())) n, d, m = gns() d += 1 ns = gns() a = [x for x in ns if x <= m] b = [x for x in ns if x > m] a.sort(reverse=True) b.sort(reverse=True) def sm(x): for i in range(1, len(x)): x[i] += x[i - 1] sm(a) sm(b) ans = 0 for i in range(len(a) + 1): j = n ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR V...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline for _ in range(1): n, d, m = map(int, input().split()) arr = list(map(int, input().split())) a, b = [], [] for i in arr: if i > m: a.append(i) else: b.append(i) a.sort(reverse=True) b.sort(reverse=True) for i in r...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL 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 VAR LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NU...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = [int(c) for c in input().split()] arr = [int(c) for c in input().split()] a = [i for i in arr if i > m] b = [i for i in arr if i <= m] k = len(a) l = len(b) a.sort(reverse=True) b.sort(reverse=True) a.insert(0, 0) b.insert(0, 0) for i in range(1, len(a)): a[i] += a[i - 1] for i in range(1, len(b)): b[...
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 VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) p = [] q = [] for x in a: if x > m: p.append(x) else: q.append(x) p = [0] + sorted(p, reverse=True) q = [0] + sorted(q, reverse=True) for i in range(len(p) - 1): p[i + 1] += p[i] for i in range(len(q) - 1): q[i + 1] ...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_C...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) n, d, m = nm() a = nl() num = 0 for i in range(n): num += a[i] <= m...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) l = list(map(int, input().split())) small = [] big = [] for i in l: if i <= m: small.append(i) else: big.append(i) small.sort(reverse=True) big.sort(reverse=True) curr = 0 pre = [0] for i in range(len(small)): pre.append(pre[-1] + small[i]) ans = pre[-1] f...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBE...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys import time buff_readline = sys.stdin.readline readline = sys.stdin.readline INF = 2**62 - 1 def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) def read_float(): return float(buff_readline()) def read_float_n(): return list(ma...
IMPORT IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def gt(): return list(map(int, input().split())) def gtsum(x): ret = x.copy() for i in range(1, len(x)): ret[i] += ret[i - 1] return ret ans = 0 n, d, m = gt() a = gt() a.sort() low = [] high = [] for val in a: if val <= m: low.append(val) else: high.append(val) sum_l...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) not_angry = [] angry = [] for i in range(n): if a[i] <= m: not_angry.append(a[i]) else: angry.append(a[i]) not_angry.sort(reverse=True) angry.sort(reverse=True) not_angry = [0] + not_angry angry = [0] + angry for i in range(...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BI...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate def chat(n, d, m, arr): lem = [] gtm = [] for x in arr: if x <= m: lem.append(x) else: gtm.append(x) lem.sort(reverse=True) gtm.sort(reverse=True) prel = [0] + list(accumulate(lem)) preg = [0] + list(accumulate(gtm)) ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate, combinations, groupby, permutations, product def solve(): n, d, m = map(int, input().split()) A = list(map(int, input().split())) over = [] safe = [] for i in range(n): if A[i] > m: over.append(A[i]) else: safe.append(A[i]) ...
FUNC_DEF 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) bigJoke = [] smallJoke = [] for elem in a: if elem > m: bigJoke.append(elem) else: smallJoke.append(elem) bigJoke.sort(reverse=True) smallJoke.sort(reverse=True) bigJokePartialSum = [0] smallJokePartialSum = [0] for elem 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 LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def main(): n, day, mood = map(int, input().split()) a = list(map(int, input().split())) out = [] safe = [] for v in a: if v <= mood: safe.append(v) else: out.append(v) safe.sort(reverse=True) out.sort(reverse=True) if not out: print(sum(sa...
FUNC_DEF 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR EXPR FUNC_CALL VAR FUNC...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) arr = list(map(int, input().split())) dp = [0] * (n + 1) arr.sort() count = 0 for i in range(n): dp[i + 1] = arr[i] + dp[i] if arr[i] <= m: count += 1 res = dp[count] for i in range(1, n - count + 1): if (i - 1) * d + i > n: break res = max( re...
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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
arr = [int(i) for i in input().split()] a = [int(i) for i in input().split()] n = arr[0] d = arr[1] m = arr[2] big = [] small = [] for i in a: if i > m: big.append(i) else: small.append(i) big = sorted(big)[::-1] n1 = len(big) ans = 0 n2 = len(small) small = sorted(small)[::-1] for i in range(1,...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def solve(a, n): a = [a[0]] + sorted(a[1:], reverse=True) for i in range(1, n + 1): a[i] += a[i - 1] return a def main(): n, d, m = map(int, input().split()) cons = list(map(int, input().split())) k = 0 l = 0 a = [(0) for _ in range(n + 1)] b = [(0) for _ in range(n + 1)] ...
FUNC_DEF ASSIGN VAR BIN_OP LIST VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF 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 NUMBER AS...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def solve(n, m, d, nums): if not nums: return 0 nums.sort(key=lambda x: x * -1) smalls = [0] bigs = [0] for num in nums: if num <= m: smalls.append(smalls[-1] + num) else: bigs.append(bigs[-1] + num) ans = 0 for x, big in enumerate(bigs): ...
FUNC_DEF IF VAR RETURN NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) arr = list(map(int, input().split())) a = [] b = [] for i in arr: if i > m: a.append(i) else: b.append(i) a.sort(reverse=True) b.sort(reverse=True) pref_a = [0] * (len(a) + 1) pref_b = [0] * (len(b) + 1) for i in range(len(a)): pref_a[i + 1] = pref_a[i] + ...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FU...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = map(int, input().split()) a = [int(item) for item in input().split()] muzzle = [] no_muzzle = [] for item in a: if item <= m: no_muzzle.append(item) else: muzzle.append(item) no_muzzle.sort(reverse=True) muzzle.sort(reverse=True) max_mnum = (n + d...
IMPORT ASSIGN VAR VAR 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 LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = list(map(int, input().split())) a = list(map(int, input().split())) small = [] big = [] for num in a: if num > m: big.append(num) else: small.append(num) big.sort() big.reverse() small.sort() small.reverse() ans = 0 small = [0] + small big = [0] +...
IMPORT ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) n1, n2 = [(0) for i in range(d)], [] for i in map(int, input().split()): if i > m: n2.append(i) else: n1.append(i) out = su = sum(n1) n1.sort(reverse=True) n2.sort(reverse=True) count = 0 for i in range(len(n2)): while n1 and count + len(n2) - i - 1 < (i +...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = [int(v) for v in input().split()] a.sort() dp = [0] c = 0 for j in range(n): dp.append(dp[-1] + a[j]) if a[j] > m: c = c + 1 res = dp[n - c] if a[-1] > m: res = res + a[-1] s = res q = 0 for j in range(1, c): p = c - 1 - j q = q + a[-j - 1] nd = ma...
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 EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR V...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) ln = list(map(int, input().split())) la = [u for u in ln if u <= m] lb = [u for u in ln if u > m] la.sort() lb.sort() na, nb = len(la), len(lb) sma, smb = [0] * (na + 1), [0] * (nb + 1) for i in range(1, na + 1): sma[i] += sma[i - 1] + la[i - 1] for i in range(1, nb + 1): smb...
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 VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys from sys import stdin n, d, m = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) a.sort() a.reverse() over = [0] below = [0] nuse = 0 for i in range(n): if a[i] > m: over.append(over[-1] + a[i]) else: below.append(below[-1] + a[i]) ans = 0 if len(over) ...
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 EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR V...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = [int(i) for i in input().split()] days = [int(i) for i in input().split()] days.sort(reverse=True) smaller = [i for i in days if i <= m] larger = [i for i in days if i > m] highest = 0 current = 0 prefix_sums = [0] * (1 + len(larger)) for i in range(0, len(larger)): prefix_sums[i + 1] = prefix_sums[i] + l...
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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR FUNC...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def main(): n, d, m = map(int, input().split()) a = list(map(int, input().split())) l1 = [] l2 = [] for i in a: if i > m: l1.append(i) else: l2.append(i) if len(l1) < 2: print(sum(a)) return l1.sort(reverse=True) l2.sort(reverse=Tru...
FUNC_DEF 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN EXPR FUNC_...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
data = [*open(0)] di = lambda x: map(int, data[x].split()) n, d, m = (*di(0),) a = (*di(1),) l1 = [] l2 = [] for ai in a: if ai > m: l1.append(-ai) else: l2.append(-ai) l1.sort() l2.sort() ans = 0 l1.insert(0, 0) l2.insert(0, 0) m1 = len(l1) m2 = len(l2) for i in range(1, m1): l1[i] = l1[i] ...
ASSIGN VAR LIST FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FU...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from itertools import accumulate n, d, m = map(int, input().split()) a = [*map(int, input().split())] ba, sa = [*filter(lambda x: x > m, a)], [*filter(lambda x: x <= m, a)] ba.sort(reverse=True) sa.sort() aba = [*accumulate(ba)] asa = [0] + [*accumulate(sa)] ans = asa[-1] for i in range(len(aba)): j = max(0, i * d...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR VAR VAR LIST FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER LIST FUNC_CALL ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) less = [] more = [] for i in a: if i > m: more.append(i) else: less.append(i) less.sort(reverse=True) more.sort(reverse=True) lessp = [] if len(less) > 0: lessp = [less[0]] for i in less[1:]: lessp.append(les...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST IF FUNC_CALL VAR VAR NU...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) an = list(map(int, input().split())) safe = [] muzz = [] for i in an: if i <= m: safe.append(i) else: muzz.append(i) muzz = list(sorted(muzz))[::-1] safe = list(sorted(safe)) spots = len(muzz) - 1 if len(muzz) > 0: ans = sum(safe) + muzz[0] muzz.pop(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 LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s) sys.stdout.write("\n") def wi(n): sys.stdout.write(str(n)) sys.stdout.write("\n") def...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF STRING EXPR FUNC_C...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.buffer.readline n, d, m = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] smaller = [] larger = [] for x in arr: if x > m: larger.append(x) else: smaller.append(x) larger.sort(reverse=True) smaller.sort(reverse=True) psL = [0] psS = [0] for...
IMPORT ASSIGN VAR VAR 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 LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys n, d, m = map(int, input().split()) a = list(map(int, input().split())) S = sum(a) a1 = [] a2 = [] for ai in a: if ai > m: a2.append(ai) else: a1.append(ai) a1.sort() a2.sort() c1 = [0] c2 = [0] for ai in a1: c1.append(c1[-1] + ai) for ai in a2: c2.append(c2[-1] + ai) if len(...
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 FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST N...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = list(map(int, input().split())) b, c = [], [] for i in range(n): if a[i] <= m: b.append(a[i]) else: c.append(a[i]) c.sort(reverse=True) b.sort() if len(b) == 0: j = len(c) - 1 ans = 0 for i in range(n): if i > j: break ...
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 LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
from sys import stdin, stdout def Boboniu_Chats_with_Du(n, d, m, a_a): b_a = [] c_a = [] res = 0 for a in a_a: if a > m: b_a.append(a) else: c_a.append(a) res += a if not b_a: return res b_a.sort(reverse=True) c_a.sort() d += ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR RETURN VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR N...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
l = input().split() n = int(l[0]) d = int(l[1]) m = int(l[2]) l = input().split() li = [int(i) for i in l] great = [] less = [] for i in li: if i > m: great.append(i) else: less.append(i) great.sort() less.sort() prefg = [0] prefl = [0] gr = len(great) le = len(less) for i in great: prefg.ap...
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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) u = list(map(int, input().split())) a = [] b = [] for i in range(n): if u[i] > m: a.append(u[i]) else: b.append(u[i]) if len(a) == 0: print(sum(b)) exit() La = len(a) Lb = len(b) a.sort(reverse=1) b.sort(reverse=1) a.append(0) b.append(0) for i in rang...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) a = [int(o) for o in input().split()] bada = [] chota = [] for i in a: if i > m: bada.append(i) else: chota.append(i) bada.sort() chota.sort() bada = bada[::-1] lb = len(bada) lc = len(chota) pb = [0] * (lb + 1) pc = [0] * (lc + 1) for i in range(lb): pb[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 LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR F...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
def main(): n, d, m = map(int, input().split()) a = list(map(int, input().split())) b = list(filter(lambda i: i > m, a)) c = list(filter(lambda i: i <= m, a)) del a b.sort(reverse=True) c.sort(reverse=True) for idx, i in enumerate(b): if idx: b[idx] += b[idx - 1] ...
FUNC_DEF 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 VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for $n$ days. On the $i$-th day: If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = map(int, input().split()) a = list(map(int, input().split())) up = [] down = [] for i in range(n): if a[i] > m: up.append(a[i]) else: down.append(a[i]) up = sorted(up) down = sorted(down) if not up: print(sum(down)) exit() ans = 0 ans += u...
IMPORT ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days. On the i-th day: * If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = map(int, input().split()) A = list(map(int, input().split())) P = [] M = [] for a in A: if a > m: P.append(a) else: M.append(a) P.sort(reverse=True) M.sort(reverse=True) if P == []: print(sum(M)) sys.exit() ANS = sum(M) + P[0] useP = 1 use...
IMPORT ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR LIST EXPR ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days. On the i-th day: * If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) ln = list(map(int, input().split())) la = [u for u in ln if u <= m] lb = [u for u in ln if u > m] la.sort() lb.sort() na, nb = len(la), len(lb) sma, smb = [0] * (na + 1), [0] * (nb + 1) for i in range(1, na + 1): sma[i] += sma[i - 1] + la[i - 1] for i in range(1, nb + 1): smb...
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 VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP ...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days. On the i-th day: * If Du can speak, he'll make fun of Boboniu ...
n, d, m = map(int, input().split()) n1, n2 = [(0) for i in range(d)], [] for i in map(int, input().split()): if i > m: n2.append(i) else: n1.append(i) out = su = sum(n1) n1.sort() n2.sort() j = 0 for i in range(len(n2) - 1, -1, -1): while j < len(n1) and i + j < d * (len(n2) - i): su...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_C...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days. On the i-th day: * If Du can speak, he'll make fun of Boboniu ...
import sys input = sys.stdin.readline n, d, m = map(int, input().split()) vals = sorted([int(i) for i in input().split()], reverse=True) over, under, over_psa, under_psa, ans = ( [i for i in vals if i > m], [i for i in vals if i <= m], [0], [0], 0, ) for i in range(len(over)): over_psa.append(o...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR LIST NUMBER LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BI...
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days. In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day. Du will chat in the group for n days. On the i-th day: * If Du can speak, he'll make fun of Boboniu ...
import sys from sys import stdin n, d, m = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) a.sort() a.reverse() over = [0] below = [0] nuse = 0 for i in range(n): if a[i] > m: over.append(over[-1] + a[i]) else: below.append(below[-1] + a[i]) ans = 0 if len(over) ...
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 EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR V...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
try: while True: n, k = map(int, input().split()) a = list(map(int, input().split())) left = 0 result = -1 cur = 0 for i in range(n): if not a[i]: if k: k -= 1 else: if i - left > resu...
WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR ...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) PI = float("inf") def fn(wl, st): l = 0 r = wl - 1 mn = PI p1 = p2 = -1 while r < n: zeros = ps[r] - (ps[l - 1] if l >= 1 else 0) if zeros <= k and zeros < mn:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VA...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
def main(): a = [int(x) for x in input().split()] legtobb = 0 b = 0 c = 0 sorozat = [int(x) for x in input().split()] helyek = [] helyek.append(-1) for x in range(len(sorozat)): if sorozat[x] == 0: helyek.append(x) helyek.append(a[0]) mo = [0, 0] if a[1] >...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR V...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
def nikita_och_ploh(a): ans = 0 b = 0 for i in a: if i == 1: b += 1 else: if b > ans: ans = b b = 0 if b > ans: ans = b return ans def nikita_plohoy(n, b, la, k): r = n + k i = n while k > 0 and r < la - 1: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR ASSIG...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) i, j, l = 0, -1, 0 z1, z2 = 0, -1 while i < n and j < n: if l <= k: if j - i + 1 > z2 - z1 + 1: z1, z2 = i, j j += 1 if j < n: l += 1 - a[j] else: break else: l ...
ASSIGN 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 VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR ...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
n, k = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, 0 ans_idx, ans_len = 0, 0 zeros = 0 while r < n: if r < n: zeros += a[r] == 0 r += 1 if zeros > k: zeros -= a[l] == 0 l += 1 if r - l > ans_len: ans_len = r - l ans_idx = l print(an...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR AS...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
s = list(map(int, input().split())) s1 = list(map(int, input().split())) start = 0 end = 0 c = 0 s2 = 0 x = 0 y = 0 while end < s[0]: if s1[end] == 0: c += 1 while c > s[1]: c += s1[start] - 1 start += 1 if end - start + 1 > s2: s2 = end - start + 1 x = start ...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER WHILE VAR VAR NUMBER VAR BIN...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
n, k = map(int, input().split()) ara = list(map(int, input().split())) max = 0 zero = 0 value = 0 end = 0 for i in range(n): if ara[i] == 0: zero += 1 if zero <= k: max += 1 end = i else: if ara[value] == 0: zero -= 1 value += 1 print(max) for i in range(e...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
n, k = map(int, input().split()) l = list(map(int, input().split())) ki = 1 p0 = 0 i = 0 s = 0 for j in range(n): if l[j] == 0: s += 1 while s > k: if l[i] == 0: s -= 1 i += 1 if j - i > p0 - ki: p0 = j ki = i print(p0 - ki + 1) for h in range(ki, p0 + 1):...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR V...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
def fu(r, a, n): e = 0 while r < n - 1: if a[r + 1] == 0: e += 1 r += 1 if e == 2: r -= 1 break return r n, k = list(map(int, input().split())) a = list(map(int, input().split())) l = 0 r = -1 c = 0 for i in range(n): if a[i] == 0: c ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN VAR ASSIGN 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 NUMBER ASSIGN VAR NUMBER A...
You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a). -----Input----- The first line contains two integers n...
n, k = map(int, input().split()) a = list(map(int, input().split())) ans = 0 b = [0, 0] t = 0 tt = n o = [] temp = 0 s = [] for i in range(n): temp += a[i] s.append(temp) o.append(tt) if a[n - i - 1] == 0: tt = n - i - 1 o.reverse() l = 0 r = -1 for i in range(n): if a[i] == 1: b[a[i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR...