description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def find(x): first = 0 last = len(temp) - 1 while first <= last: mid = (first + last) // 2 if temp[mid] == x: return mid elif x < temp[mid]: first = mid + 1 elif x > temp[mid]: last = mid - 1 return -1 n, m, k = map(int, input().split...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) v = sorted(enumerate(a), key=lambda x: x[1], reverse=True)[: m * k] v = list(sorted(v)) print(sum(map(lambda x: x[1], v))) for i in range(m, m * k, m): print(v[i][0], end=" ") print()
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) l = list(map(int, input().split())) sumi = 0 l = list(enumerate(l)) list = [0] * n l.sort(key=lambda x: x[1]) l.reverse() for i in range(m * k): list[l[i][0]] = 1 sumi += l[i][1] ans = [] count = 0 for i in range(n - 1): if len(ans) == k - 1: break if list[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 NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) a = [[a[i], i] for i in range(n)] a.sort(key=lambda x: x[0], reverse=True) a = a[: m * k] a.sort(key=lambda x: x[1]) s = 0 for i in range(m * k): s += a[i][0] print(s) for i in range(m - 1, m * k - 1, m): print(a[i][1] + 1, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_O...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
from sys import stdin input = stdin.readline def f(a, m, k): b = list(zip(a, range(0, len(a)))) b = sorted(b, key=lambda s: s[0], reverse=True) big = b[: m * k] s = 0 for i in big: s += i[0] big = sorted(big, key=lambda s: s[1]) cb = 0 pt = 0 lb = len(big) ans = [] ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def main(): [n, m, k] = list(map(int, input().split(" "))) ar = list(map(int, input().split(" "))) orderedAr = ar[:] orderedAr.sort(reverse=True) items = m * k new = orderedAr[:items] f = dict() for i in new: if i not in f: f[i] = 1 else: f[i] += 1...
FUNC_DEF ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR N...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) tab = map(int, input().split()) tab = [(t, i) for i, t in enumerate(tab)] tab.sort() want = [(False) for _ in range(n)] for _, i in tab[n - k * m :]: want[i] = True counter = 0 print(sum(t for t, i in tab if want[i])) printed = 0 for i, w in enumerate(want): counter += w ...
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 VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def main(): n, m, k = map(int, input().split()) arr = list(map(int, input().split())) max_nums = {} arr1 = arr[:] arr1.sort(reverse=True) total = 0 for i in range(m * k): if arr1[i] not in max_nums.keys(): max_nums[arr1[i]] = 1 else: max_nums[arr1[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 DICT ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def do_task(a, n, m, k): a_sorted = sorted(enumerate(a), key=lambda x: x[1]) s = [x[0] for x in a_sorted] s = s[::-1] s = s[: m * k] s.sort() result = 0 for i in range(m * k): result += a[s[i]] print(result) splits = [] for i in range(m - 1, k * m - 1, m): splits....
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] sortedA = sorted(a, reverse=True) freqLar = {} sum = 0 for i in range(m * k): sum += sortedA[i] if i > 0 and sortedA[i] == sortedA[i - 1]: freqLar[sortedA[i]] += 1 else: freqLar[sortedA[i]] = 1 mn = sortedA[m *...
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 VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) a1 = [] for i in range(n): a1.append((a[i], i)) a1.sort(reverse=True) _max = [0] * n ans = 0 for i in range(m * k): _max[a1[i][1]] = 1 ans += a1[i][0] print(ans) _sum = 0 ans_ar = [] for i in range(n): _sum += _max[i] if _sum ==...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSI...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) x = [] for i in range(n): x.append((a[i], i)) x.sort(reverse=True) total = 0 check = [] len = 0 for i in range(k * m): total += x[i][0] check.append(x[i][1]) len += 1 check.sort() print(total) temp = k - 1 count = 0 for i in range(l...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def get(): return list(map(int, input().split())) n, m, k = get() a = get() b = sorted(a) c = b[-(m * k) :] f = c.count(c[0]) r = 0 s = sum(b[-(m * k) :]) l = [] for i in range(n): if a[i] > c[0] or a[i] == c[0] and f > 0: if a[i] == c[0]: f -= 1 r += 1 if r == m: ...
FUNC_DEF RETURN 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 FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) nums = list(map(int, input().split())) for i, num in enumerate(nums): nums[i] = {"value": num, "ind": i} nums = sorted(nums, key=lambda x: x["value"], reverse=True) beauty, indexes = 0, [] for i in range(m * k): indexes.append(nums[i]["ind"]) beauty += nums[i]["valu...
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 FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR DICT STRING STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING NUMBER ASSIGN VAR VAR NUMBER LIST FOR VAR FUNC_CALL VAR BIN_OP VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = enumerate(list(map(int, input().split())), 1) arr = sorted(arr, key=lambda x: x[1], reverse=True) ind = [arr[i][0] for i in range(m * k)] ind.sort() ans = [ind[i] for i in range(m - 1, m * (k - 1), m)] print(sum(arr[i][1] for i in range(m * k))) print(*ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def solve(n, m, k, arr): newArr = [] for i in range(n): newArr.append((arr[i], i)) newArr.sort(key=lambda x: x[0], reverse=True) mk = m * k largeNums = {} for i in range(mk): largeNums[newArr[i]] = 1 ans = 0 ansArr = [] seg = 0 numInSeg = 0 maxNums = 0 tem...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
lin = [int(i) for i in input().split()] n = lin[0] m = lin[1] k = lin[2] a = [int(i) for i in input().split()] vet = [] for i in range(n): vet.append([a[i], i]) vet.sort(reverse=True) sp = [False] * n ans = 0 for i in range(k * m): sp[vet[i][1]] = True ans += vet[i][0] ini = [] cnt = 0 for i in range(n): ...
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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR AS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(item) for item in input().split()] a = [int(item) for item in input().split()] best = {key: (0) for key in sorted(a)[-m * k :]} for x in sorted(a)[-m * k :]: best[x] += 1 print(sum(x * best[x] for x in best)) cnt = 0 parts = 1 for i in range(n): if parts == k: break if a[i] in best an...
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 NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIG...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def check(): n, m, k = [int(x) for x in input().split()] s = [int(x) for x in input().split()] a = [] stop = [] for i in range(n): a += [(int(s[i]), i)] aa = sorted(a, key=lambda x: x[0], reverse=True) aa = aa[: m * k] ans = 0 for e in aa: ans += e[0] counter = 0 ...
FUNC_DEF 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 FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [] for i in range(n): b.append((a[i], i + 1)) b.sort(reverse=True) c = b[: m * k] c.sort(key=lambda x: x[1]) ans = 0 for i in c: ans += i[0] print(ans) for i in range(len(c) - 1): if (i + 1) % m == 0: print(c[i][1], end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = sorted(enumerate(a), key=lambda x: (x[1], x[0]), reverse=True) b = b[: m * k] b = sorted(b) rec = [] s = 0 tmp = 0 for i in range(len(b)): tmp += 1 if tmp == m: rec.append(b[i][0] + 1) tmp = 0 s += b[i][1] print(s) p...
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 NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR F...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] b = sorted(a) s = 0 if m * k == n: print(sum(a)) for i in range(m, n, m): print(i, end=" ") else: count = 0 p = b[n - m * k] print(sum(b[n - m * k :])) for i in range(n - m * k, n): if b[i] == p: ...
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 VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().strip().split()) l = [(int(x), i) for i, x in enumerate(input().strip().split())] l.sort(key=lambda x: x[0], reverse=True) u = m * k sums = 0 l1 = [] for i in range(u): sums += l[i][0] l1.append(l[i][1]) l1.sort() l2 = [] print(sums) for i in range(k - 1): l2.append(l1[(i + 1) * m...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) ind = [x for x in range(n)] ind = [i for j, i in sorted(zip(a, ind), reverse=True)] index = [] s = 0 for i in range(m * k): s += a[ind[i]] index.append(ind[i]) print(s) index.sort() for i in range(k - 1): print(index[(i + 1) * m -...
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 VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) b = a.copy() b.sort(reverse=True) msum = sum(b[: m * k]) count = {} for i in range(m * k): count[b[i]] = count.get(b[i], 0) + 1 if n == 2: if k == 2: print(sum(a)) print(1) elif m == 1: print(max(a)) ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) b = sorted([(a[i], i) for i in range(n)]) ok = [0] * n ans = 0 for x, i in b[-k * m :]: ok[i] = 1 ans += x t = 0 li = [] for i in range(n): t += ok[i] if ok[i] and t % m == 0: li += [i + 1] print(ans) print(*li[:-1])
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
N, M, K = map(int, input().split()) a_list = list(map(int, input().split())) b_list = [i for i in range(N)] b_list.sort(reverse=True, key=lambda x: a_list[x]) c_list = [] sum_beauties = 0 for i in range(K * M): sum_beauties += a_list[b_list[i]] c_list.append((a_list[b_list[i]], b_list[i])) print(sum_beauties) c...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] pairs = [(a[i], i) for i in range(len(a))] sorted_a = sorted(pairs, reverse=True)[: m * k] grid = [0] * len(a) for x, i in sorted_a: grid[i] = 1 s = 0 print(sum([p[0] for p in sorted_a])) cnt = 0 for i, val in enumerate(grid): s +...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR VAR NUMBER AS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
from sys import stdin def compute(): n, m, k = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) i = sorted(enumerate(a), key=lambda p: (-p[1], p[0])) res = sum(map(lambda p: p[1], i[: m * k])) p = list(sorted(map(lambda p: p[0], i[: m * k])))[m : m * k : m] retur...
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 NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
line1 = input() line2 = input() n, m, k = map(int, line1.split()) nums = list(map(int, line2.split())) nums_copy = nums.copy() nums_copy.sort() counter = {} res1 = 0 res2 = [] for num in nums_copy[n - m * k :]: counter[num] = counter.get(num, 0) + 1 res1 += num cnt = 0 for index, num in enumerate(nums): if ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CAL...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) p = list([x, i] for i, x in enumerate(map(int, input().split()), 1)) p.sort(reverse=True) l = [] s = 0 for i in range(m * k): s += p[i][0] l.append(p[i][1]) print(s) l.sort() for i in range(m - 1, len(l) - 1, m): print(l[i], end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) A = list(map(int, input().split())) B = list(enumerate(A)) B.sort(key=lambda x: x[1]) B.reverse() LIST = [0] * n ANS = 0 for i in range(m * k): LIST[B[i][0]] = 1 ANS += B[i][1] ANSLIST = [] count = 0 for i in range(n): if LIST[i] == 1: count += 1 if count == m...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(i) for i in input().strip().split()] nums = [int(i) for i in input().strip().split()] beauty_num = m * k num_sort = sorted(nums, reverse=True)[:beauty_num] num_dict = dict() for i in num_sort: if i not in num_dict: num_dict[i] = 1 else: num_dict[i] += 1 counter = 0 ans = [] for i ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = map(int, input().split()) lengthMemory = [] for index, elem in enumerate(a): lengthMemory.append((elem, index)) lengthMemory.sort(reverse=True) beauty = sum(map(lambda x: x[0], lengthMemory[: m * k])) print(beauty) indexGroup = [] for elem in lengthMemory[: m * k]: indexG...
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 LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = sorted(a) d = {} for i in range(m * k): d[b[n - 1 - i]] = d.get(b[n - 1 - i], 0) + 1 c = 0 kk = [] print(sum(b[::-1][: m * k])) for i in range(n): if d.get(a[i], 0) > 0: d[a[i]] -= 1 c += 1 if c == m: c = 0 ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBE...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = tuple(map(int, input().split())) A = list(map(int, input().split())) B = A[:] B.sort() B = B[-(m * k) :] maximal = {} summa = 0 for i in B: maximal[i] = maximal.get(i, 0) + 1 summa += i B = set(B) count_max = 0 counter = 0 print(summa) for i in range(n): if A[i] in B and maximal[A[i]] != 0: ...
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 VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR ASSIGN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = [int(s) for s in input().split()] a_sorted = sorted(a, reverse=True) min_take = a_sorted[m * k - 1] needed_min = 0 for i in range(m * k - 1, -1, -1): if a_sorted[i] == min_take: needed_min += 1 su = 0 for i in range(m * k): su += a_sorted[i] part = [] takes = 0 fo...
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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NU...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
s = input().split() n = int(s[0]) m = int(s[1]) k = int(s[2]) s = input().split() a = [int(i) for i in s] a_descend = [] for index, num in enumerate(a): a_descend.append((num, index)) a_descend = sorted(a_descend, reverse=True) ans_sum = 0 flg = [(False) for _ in range(n)] for i in range(m * k): flg[a_descend[i...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUM...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = [] i = 0 for item in input().split(): a.append((int(item), i)) i += 1 a.sort(reverse=True) c = 0 index = [] for i in range(m * k): c += a[i][0] index.append(a[i][1]) print(c) index.sort() for i in range(m - 1, m * k - 1, m): print(index[i] + 1, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) ls = list(map(int, input().split())) ls2 = ls.copy() ls2.sort() d = {} count = 0 ans = 0 for x in reversed(ls2): r = int(x) ans = ans + r if r in d: d[r] = d[r] + 1 else: d[r] = 1 count = count + 1 if count == m * k: break ls1 = list() ...
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 EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSI...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(i) for i in input().split()] A = [int(i) for i in input().split()] B = sorted(A, reverse=True) b = int(1000000000000000.0) cnt = 0 ans = sum(B[: m * k]) for i in range(m * k): if b == B[i]: cnt += 1 else: cnt = 1 b = B[i] P = [] cnt_e = 0 cnt_b = 0 for i, a in enumerate(A)...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIG...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) list_1 = [int(i) for i in input().split()] total = m * k sorter = sorted(list_1, reverse=True)[:total] print(sum(sorter)) board = sorter.count(sorter[m * k - 1]) num = 0 out = [] for i in range(n): if list_1[i] > sorter[m * k - 1]: num += 1 elif board > 0 and list_1[i...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = list(map(int, input().split())) sa = 0 arr_ind = [[c, i] for i, c in enumerate(arr)] arr_ind.sort() flag = [0] * n for j in range(n - 1, n - 1 - m * k, -1): sa += arr_ind[j][0] flag[arr_ind[j][1]] = 1 print(sa) s = 0 t = 1 for i in range(n): s += flag[i] if s //...
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 ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, k, m = map(int, input().split()) xs = list(map(int, input().split()))[:n] helper = sorted(list(zip(xs, range(len(xs)))), reverse=True) needed = helper[: k * m] needed = sorted(needed, key=lambda x: x[1]) result = sum([x[0] for x in needed]) print(result) for i in range(k, len(needed), k): print(needed[i][1], end...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(x) for x in input().strip().split(" ")] a = [int(x) for x in input().strip().split(" ")] limit = sorted(a)[n - m * k] index = 0 drop = 0 while index < n and drop < n - m * k: if a[index] < limit: drop += 1 a[index] = None index += 1 index = 0 while index < n and drop < n - m * k: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASS...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) listo = list(map(int, input().split())) lis = listo.copy() lis.sort(reverse=True) cand = {} s = 0 for i in range(m * k): s += lis[i] if lis[i] in cand: cand[lis[i]] += 1 else: cand[lis[i]] = 1 cnt = 0 sol = [] for i in range(n): if listo[i] in cand: ...
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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBE...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) l = list(map(int, input().split())) ans = [] for i in range(n): ans.append([l[i], i]) ans.sort(reverse=1) sum = 0 ans1 = [] for i in range(m * k): sum += ans[i][0] ans1.append(ans[i][1] + 1) print(sum) ans1.sort() for i in range(m - 1, len(ans1) - 1, m): print(ans1[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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBE...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = (int(x) for x in input().split()) arr = [int(x) for x in input().split()] sorted_enum = list(sorted(enumerate(arr), key=lambda x: -x[1]))[: m * k] sorted_enum = sorted(sorted_enum, key=lambda x: x[0]) max_sum = 0 arr = [] for i in range(k): sm = sum([x[1] for x in sorted_enum[i * m : (i + 1) * m]]) ar...
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 VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) fin = sorted(a, reverse=True)[: k * m] s = sum(fin) d = dict() for i in fin: if i in d: d[i] += 1 else: d[i] = 1 print(s) count = 0 for i in range(n): if a[i] in d and d[a[i]] > 0: count += 1 d[a[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 FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSI...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
r = [int(x) for x in input().split()] n = r[0] m = r[1] k = r[2] a = [int(x) for x in input().split()] arr = [] for i in range(n): arr.append([a[i], i]) arr.sort() arr.reverse() brr = [] sum = 0 for i in range(m * k): brr.append([arr[i][1], arr[i][0]]) sum += arr[i][0] brr.sort() print(sum) for i in range(m...
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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = sorted(a, reverse=True) t = b[m * k - 1] idx = b.index(t) valid = m * k - idx count = 0 v = 0 ans = [] for i in range(n): if a[i] > t or a[i] == t and v < valid: count += 1 if a[i] == t: v += 1 if count >...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def check(val): return b[m * k - 1] <= val n, m, k = map(int, input().split()) i = 0 a = [] b = [] for x in input().split(): a.append((int(x), i)) b.append((int(x), i)) i += 1 b.sort() b.reverse() res = 0 p = [] cnt = 0 for i in range(n): if check(a[i]): cnt += 1 res += a[i][0] ...
FUNC_DEF RETURN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
R = lambda: map(int, input().split()) n, m, k = R() L = list(R()) S = sorted(L) ind = n - m * k e = S[ind] c = 1 while ind < n - 1: if S[ind] == S[ind + 1]: c += 1 else: break ind += 1 res = [] ans = 0 p = m for i in range(n): if L[i] > e: p -= 1 ans += L[i] elif L[i]...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = input().split() n = int(n) m = int(m) k = int(k) a = [int(x) for x in input().split()] b = a.copy() a.sort(reverse=True) sp = sum(a[0 : m * k]) temp = a[0 : m * k] start = 0 print(sp) t = 0 c = 0 temp2 = dict() for i in range(len(temp)): if temp[i] in temp2: temp2[temp[i]] += 1 else: t...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) lista = sorted(map(lambda x: (x[1], x[0]), enumerate(map(int, input().split()))))[ -m * k : ] [l1, l2] = zip(*lista) print(sum(l1)) print(*list(map(lambda x: x + 1, sorted(l2)[m - 1 :: m]))[: k - 1])
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_O...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) l = [int(x) for x in input().split()] ll = [(l[i], i) for i in range(n)] ll.sort(key=lambda x: x[0], reverse=True) ans, idx = 0, [] for i in range(m * k): ans += ll[i][0] idx.append(ll[i][1]) idx.sort() print(ans) for i in range(k - 1): print(idx[(i + 1) * m - 1] + 1, end...
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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXP...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) b = sorted(a, reverse=True) middle = b[m * k - 1] nm = b[: m * k].count(middle) sum = sum(b[: m * k]) ind = [] c = 0 cut = 0 cm = 0 for i in range(len(a)): if a[i] >= middle: if a[i] == middle: if cm < nm: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [] ok = [1] * n for i in range(n): b.append([a[i], i]) b.sort() ans = 0 for i in range(n): ans += a[i] for i in range(n - m * k): ans -= b[i][0] ok[b[i][1]] = 0 cnt = 0 print(ans) for i in range(n - 1): cnt += ok[i] if c...
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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR FOR V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = input() nums = [int(n) for n in arr.split()] s = list(enumerate(nums)) s.sort(key=lambda x: x[1], reverse=True) s = s[: m * k] sum = sum(x[1] for x in s) print(sum) s = [x[0] for x in s] s.sort() for i in range(m, m * k, m): print(s[i - 1] + 1, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = input().split() n = int(n) m = int(m) k = int(k) arr = input().split() a = [int(i) for i in arr] c = [i for i in a] a.sort() rem = n - m * k h = {} for i in a: h[i] = 0 for i in range(rem): h[a[i]] += 1 l = 0 b = [] su = 0 for i in range(n): if h[c[i]] == 0: l += 1 su += c[i] e...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) b = [(a[i], i) for i in range(n)] b.sort(reverse=True) c = [0] * n sm = 0 for i in range(m * k): sm += b[i][0] c[b[i][1]] = 1 i = 0 p = [] while i < n: j = i cnt = 0 while j < n and cnt < m: cnt += c[j] j += 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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
R = lambda: map(int, input().split()) n, m, k = R() a = sorted(zip(R(), range(n)))[-m * k :] print(sum(x for x, _ in a), *sorted(i + 1 for _, i in a)[m - 1 : -1 : m])
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def main(): n, m, k = list(map(int, input().split())) a = list(map(int, input().split())) ret = sum(a) index = list(range(n)) index.sort(key=lambda i: a[i]) rm_flag = [False] * n for i in range(n - m * k): rm_flag[index[i]] = True ret -= a[index[i]] pos, cnt = [], 0 f...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR BIN...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = list(map(int, input().split())) arr2 = [x for x in arr] arr2.sort() indices = [] high = arr2[-k * m :][0] highcount = arr2[-k * m :].count(high) temp = m count = 1 total = 0 for i in range(n): if arr[i] > high or arr[i] == high and highcount > 0: total += arr[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 VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FO...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) mas = list(map(int, input().split())) qu = {} for i in sorted(mas, reverse=True)[: k * m]: if not i in qu.keys(): qu[i] = 0 qu[i] += 1 otv = [] c = 0 for i in range(n): if mas[i] in qu.keys() and qu[mas[i]] > 0: qu[mas[i]] -= 1 c += 1 if c == m...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) l = list(map(int, input().split())) a = n // k su = 0 li = (a - 1) * k for i in range(n): l[i] = i + 1, l[i] l.sort(reverse=True, key=lambda x: x[1]) lol = m * k for i in range(lol): su = su + l[i][1] l = l[: m * k] print(su) kk = 0 l.sort() for i in range(m, m * k, m): p...
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 VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSI...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] for i in range(n): a[i] = [a[i], i] num_required = m * k a.sort() candidate = a[n - num_required : n] len_cand = len(candidate) beauty = 0 for x in range(len_cand): beauty += candidate[x][0] candidate[x][0], candidate[x][1] = ...
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_C...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) cl = list(map(int, input().split())) pl = sorted(cl) dic = {} for i in range(n - m * k, n): dic.update({pl[i]: 1}) pos = pl[n - m * k] p = pl[n - m * k :].count(pos) for i in range(n - m * k): if pl[i] != pos: dic.update({pl[i]: 0}) count = 0 ans = [] sm = sum(pl[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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR DICT VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
nmk = input().split() n = int(nmk[0]) m = int(nmk[1]) k = int(nmk[2]) a = input().split() for i in range(len(a)): a[i] = int(a[i]) b = [] for i in range(len(a)): b.append([a[i], i]) b.sort(reverse=1) sum = 0 c = [] for i in range(m * k): sum = sum + b[i][0] c.append(b[i][1]) print(sum) c.sort() for i in...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def inpl(): return list(map(int, input().split())) N, M, K = inpl() A = [(int(v), i) for i, v in enumerate(input().split(), 1)] A.sort(reverse=True) H = dict() for j, (_, i) in enumerate(A, 1): H[i] = j ctr = 0 ans = [] sumans = 0 for i in range(1, N + 1): pre = ctr if H[i] <= K * M: ctr += 1 ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) c = [] for i in range(n): c.append([a[i], i]) b = sorted(c, reverse=True) def f(m, a): s = 0 b = sorted(a, reverse=True) for i in range(m): s += b[i] return s ans = [] for i in range(m * k): ans.append(b[i]) sum ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) A = list(map(int, input().split())) a = list(enumerate(A)) a.sort(key=lambda x: x[1]) f = [0] * (n + 100) ans = 0 ANS = [] for i in range(n - m * k): f[a[i][0]] = 1 t = 0 tt = 0 for i in range(n): t += 1 ans += A[i] if f[i] == 1: t -= 1 ans -= 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 FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR BIN_...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
input = __import__("sys").stdin.readline print = __import__("sys").stdout.write n, m, k = map(int, input().split()) tmp = list(map(int, input().split())) r = sorted(tmp, reverse=True)[: m * k] min_val = min(r) print(str(sum(r)) + "\n") d = {} for i in r: if i not in d: d[i] = 1 else: d[i] += 1 i...
ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CAL...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
from sys import stdin n, m, k = map(int, stdin.readline().strip().split()) s = list(map(int, stdin.readline().strip().split())) s1 = s.copy() s1.sort(reverse=True) x = m * k s1 = s1[0:x] d = dict() for i in s1: if i not in d: d[i] = 1 else: d[i] += 1 x = 0 ans = [] y = 1 for i in range(n): ...
ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def main(): n, m, k = map(int, input().split()) a = list(map(int, input().split())) if n == k: print(sum(a)) print(" ".join([str(i) for i in range(1, n)])) return r = sorted(a, reverse=True)[: m * k] target = r[-1] r = r.count(r[-1]) obj = 0 tmp = [] result = ...
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 IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR RETURN ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VA...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) arr = list(map(int, input().split())) arr1 = sorted(arr) a = arr1[-m * k :] d = {} for i in a: d[i] = d.get(i, 0) + 1 print(sum(a)) p = 0 t = 0 for i in range(n): if arr[i] in d: d[arr[i]] -= 1 t += 1 if d[arr[i]] == 0: del d[arr[i]] 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 FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUM...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().split()) a = list(map(int, input().split())) array_with_id = [(a[i], i + 1) for i in range(n)] array_with_id.sort(reverse=True) important_ids = [item[1] for item in array_with_id[: m * k]] important_ids.sort() sum_beauty = 0 for i in important_ids: sum_beauty += a[i - 1] partitions = [] 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 VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR BIN_O...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
n, m, k = map(int, input().strip().split()) l = list(map(int, input().strip().split())) b = sorted(range(len(l)), key=lambda k: l[k]) b.reverse() b = b[: m * k] b.sort() sm = 0 ans = [] for i in range(len(b)): if i % m == 0 and i != 0: ans.append(b[i]) sm += l[b[i]] print(sm) for i in ans: print(i, ...
ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR V...
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$. Suppose $m$ is some known constant. For any array, having $m$ or more elements, let's define it's beauty as the sum of $m$ largest elements of that...
def go(): n, m, k = [int(i) for i in input().split(" ")] original = [int(i) for i in input().split(" ")] a = sorted(original, reverse=True) d = {} for i in range(m * k): d.setdefault(a[i], 0) d[a[i]] += 1 c = 0 r = 0 o = [] for i in range(n): if original[i] in...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMB...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
def solve(n, k, s): gaps = [] first_w_index = -1 last_w_index = -1 score = 0 win_streak = 0 for i in range(n): if s[i] == "W": win_streak += 1 if first_w_index == -1: first_w_index = i elif i - last_w_index - 1 > 0: gaps...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP NUMBE...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) string = list(input()) lis = [] i = 0 j = n - 1 counter = 0 for _i_ in string: if _i_ != "W": counter += 1 i += 1 else: break b1 = counter, 0 counter = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR N...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
import sys input = lambda: sys.stdin.readline() int_arr = lambda: list(map(int, input().split())) str_arr = lambda: list(map(str, input().split())) get_str = lambda: map(str, input().split()) get_int = lambda: map(int, input().split()) get_flo = lambda: map(float, input().split()) mod = 1000000007 def solve(n, k, s)...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) for i in range(t): n, k = map(int, input().strip(" ").split(" ")) s = input().strip(" ") ind = s.find("W") if ind == -1: if k == 0: print(0) else: print(2 * k - 1) continue pre = 1 c = 0 lcount = [] wins = 1 winningstre...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NU...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
T = int(input()) for t in range(T): N, K = [int(_) for _ in input().split()] initK = K s = input() nb_l = len([c for c in s if c == "L"]) current_score = 0 current_nb = 0 current_c = None loss_group_sizes = [] has_won = False for c in s: if c == current_c: cur...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR V...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) arr = [] for _ in range(t): n, k = tuple(map(int, input().split())) arr.append((n, k, input())) for n, k, string in arr: numL = 0 Lchain = string.split("W") Lchain = list(map(lambda x: len(x), Lchain)) Wchain = string.split("L") Wchain = list(map(lambda x: len(x), Wchain)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) for t1 in range(t): n, final = [int(n1) for n1 in input().split()] s = list(str(input())) d = [] k = [] count = 0 if s[0] == "W": count = 1 else: count = 0 i = 0 first = -1 earlier_count = 0 prev = "L" while i < len(s): if s[i] == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) for i in range(t): n, k = map(int, input().split()) s = [] w = input() for j in w: s.append(j) p = k res = [] j = 0 while j < n: if s[j] == "W": res.append(j) j += 1 if len(res) == 0: j = 0 while j < n: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR NUMBER IF FUNC...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
t = int(input()) for _ in range(t): l = list(map(int, input().split())) n, k = l[0], l[1] s = str(input()) score = 0 key = 1 for i in range(n): if s[i] == "L": key = 1 else: score += key key = 2 l = [] count, count2 = 0, 0 ind = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR VAR ASSIGN...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) string = input().strip() if "W" not in string: ans = min(n, k) * 2 - 1 print(max(ans, 0)) return L_s = [] cnt = 0 bef = string[0] ans = 0 for s in string: if s == bef: ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF STRING VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMB...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
nums = int(input().strip()) for _ in range(nums): n, k = map(int, input().strip().split()) s = input().strip() lw, rw = s.find("W"), s.rfind("W") res = cur_num = 0 if lw == rw: if lw == -1: res = 2 * k - 1 else: res = 2 * k + 1 res = min(2 * len(s) - 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER IF VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUM...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = input().strip() curr = n + 100 streaks = [] out = 0 wins = k for i in range(n - 1): if s[i] == "W" and s[i + 1] == "W": out += 1 for c in s: if c ==...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR B...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() L = s.count("L") W = s.count("W") score = 0 if s[0] == "W": score += 1 for i in range(1, n): if s[i] == "W": if s[i - 1] == "W": score += 2 else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR BIN_OP VAR NUMBE...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
for _ in range(int(input())): n, k = list(map(int, input().split())) a = list(input()) yes = 0 if a[0] == "W": ans = 1 yes = 1 c = 0 else: ans = 0 c = 1 r = [] first = 0 for i in range(1, n): if a[i] == "W" and a[i - 1] == "W": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMB...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
for _ in range(int(input())): n, k = list(map(int, input().split())) s = input() i = 0 first = 0 last = 0 res = 0 while i < n and s[i] != "W": i += 1 first += 1 intervals = [] while i < n: start = i while i < n and s[i] == "W": if i > start...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR VAR WHILE ...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
import sys inp = sys.stdin.buffer.readline inar = lambda: list(map(int, inp().split())) inin = lambda: int(inp()) inst = lambda: inp().decode().strip() wrt = sys.stdout.write pr = lambda *args, end="\n": wrt(" ".join([str(x) for x in args]) + end) enum = enumerate inf = float("inf") cdiv = lambda x, y: -(-x // y) _T_ ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
T = int(input()) for _ in range(0, T): n, k = map(int, input().split()) L = input() s = [] for i in range(0, len(L)): s.append(L[i]) ptr = len(s) for i in range(0, len(s)): if s[i] == "W": ptr = i break dp = [] c = 0 st = ptr for i in range...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
for _ in range(int(input())): n, k = map(int, input().split()) s = list(input()) l = [] prev = 0 c = 0 f = 0 for i in range(n): if s[i] == "L": if f == 0: ind = i f = 1 prev = i c += 1 else: if c ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VA...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
for _ in range(int(input())): n, k = map(int, input().split()) inp = input().lower() k = min(k, inp.count("l")) ans = inp.count("w") + tuple(zip(inp, "l" + inp)).count("ww") + k * 2 if "w" in inp: inp2 = [] cur = -1 for c in inp: if cur != -1: if c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP STRING VAR STRING BIN_OP VAR NUMB...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
cases = int(input()) for t in range(cases): n, k = list(map(int, input().split())) s = input() fw = s.find("W") lw = s.rfind("W") s = list(s) ls = [] for i in range(fw + 1, n): if s[i] == "L" and s[i - 1] == "W": st = i elif s[i] == "W" and s[i - 1] == "L": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR...
You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you get $2$ points, otherwise ...
def solve(): n, m = map(int, input().split()) s = input() s = s[:n] p = 0 gaps = [] points = 0 lastsect = 0 firstsect = 0 wins = len(list(filter(lambda x: x == "W", s))) if wins == 0: m = min(m, n) if m == 0: print(0) else: print(2 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR ...