description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys from itertools import accumulate def main(): n, k = [int(x) for x in sys.stdin.readline().split(" ")] arr = [int(x) for x in sys.stdin.readline().split(" ")] arr.sort() total = 0 dp = [(0) for x in range(n)] prefix = list(accumulate(arr)) for i, elem in enumerate(arr): i...
IMPORT FUNC_DEF ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMB...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, k = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) if n == 1: print(a[0]) quit() b = [0] * n b[0] = a[0] for i in range(1, n): b[i] = b[i - 1] + a[i] if n <= k: print(" ".join(str(k) for k in b)) quit() ans = [] sums = [] for i in range(k): sums.append([b[i]]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().strip().split()) arr = list(map(int, input().strip().split())) arr.sort() sumi = [(0) for i in range(n)] for i in range(m): sumi[i] = arr[i] for i in range(m, n): sumi[i] = arr[i] + sumi[i - m] temp = 0 for i in range(n): temp += sumi[i] print(temp, end=" ")
ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) it = list(map(int, input().split())) if n == 1: print(it[0]) else: it.sort() tot = 0 cu = 0 d = 1 fi = it[0] aa = [(0) for i in range(m)] tt = [] for i in range(n): tot += aa[(i - (m - 1)) % m] aa[i % m] += it[i] if tot != 0 an...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST F...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
N, M = map(int, input().split()) A = sorted([int(a) for a in input().split()]) B = [a for a in A] for i in range(M, N): B[i] = B[i - M] + A[i] s = 0 ANS = [] for i in range(N): s += A[i] if i >= M: s += B[i - M] ANS.append(s) print(*ANS)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() extra_penalty = [] for i in range(n): if i < m: extra_penalty.append(a[i]) else: extra_penalty.append(a[i] + extra_penalty[i - m]) res = [] for i in range(n): if i < 1: res.append(extra_penalty[i]) else...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys input = sys.stdin.readline N, M = map(int, input().split()) A = list(map(int, input().split())) A.sort() D = [0] * M s = 0 ans = [] for i, a in enumerate(A): D[i % M] += a s += D[i % M] ans.append(s) print(" ".join([str(a) for a in ans]))
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_C...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = tuple(map(int, input().split())) arr = list(map(int, input().split())) arr.sort() prefix_sum = [0] * n prefix_sum[0] = arr[0] for i in range(1, n): prefix_sum[i] = prefix_sum[i - 1] + arr[i] ans = [0] * (n + 1) for k in range(1, m + 1): sm = 0 days = (k + m - 1) // m i = k - 1 for d in range(...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys class CSweetsEating: def solve(self): n, m = [int(_) for _ in input().split()] a = [int(_) for _ in input().split()] a.sort() pre = [0] * (n + 2) pre[1] = a[0] for i in range(1, n + 1): pre[i] = pre[i - 1] + a[i - 1] blockpre = [0] * ...
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(x) for x in input().split(" ")] alist = [int(x) for x in input().split(" ")] alist.sort() slist = [] mm = [0] * (n + 1) a = [0] * (n + 1) s = 0 for i in range(n): s += alist[i] slist.append(s) for j in range(1, n + 1): t = alist[j - 1] if j - 1 >= m: t += mm[j - 1 - m] mm[j - 1] ...
ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR E...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = [(0) for i in range(n)] s = 0 for i in range(len(a)): s = s + a[i] ans[i] = s if i >= m: ans[i] = ans[i] + ans[i - m] print(*ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) a1 = [0] * n for i in range(m): a1[i] = a[i] for i in range(m, n): a1[i] += a[i] + a1[i - m] for i in range(1, m): a1[i] += a1[i - 1] c = 1 s = 0 for i in range(n - 1, -1, -m): for j in range(i, max(-1, i - m), -1):...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = input().split() n, m = int(n), int(m) A = input().split() A = [int(ai) for ai in A] A.sort() D = [] for i, a in enumerate(A): if i < m: D.append(A[i]) else: D.append(A[i] + D[i - m]) P = [D[0]] for i in range(1, n): P.append(P[-1] + D[i]) print(" ".join([str(pi) for pi in P]))
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR AS...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) s = list(map(int, input().split())) s.sort() d = 1 for i in range(1, n): s[i] += s[i - 1] for i in range(m, n): s[i] += s[i - m] for i in range(n): print(s[i], end=" ")
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
fl = input().split(" ") n = int(fl[0]) m = int(fl[1]) a = [int(ai) for ai in input().split(" ")] sortd = sorted(a) penalties = [] my_sum = [sortd[0]] for i in range(1, len(sortd)): my_sum.append(my_sum[-1] + sortd[i]) ans = [] for i in range(m): ans.append(my_sum[i]) for i in range(m, n): ans.append(ans[i -...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
from sys import stdin, stdout input = stdin.readline n, m = map(int, input().split()) a = sorted(list(map(int, input().split()))) k = [a[0]] * n for i in range(1, n): k[i] = k[i - 1] + a[i] for i in range(m, n): k[i] += k[i - m] for i in k: stdout.write(str(i)) stdout.write(" ")
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
inln = [int(i) for i in input().split(" ")] n = inln[0] m = inln[1] ln = [int(i) for i in input().split(" ")] ln = sorted(ln) cds = [] mds = [0] * m s = 0 for i in range(0, len(ln)): s += ln[i] + mds[i % m] cds.append(s) mds[i % m] += ln[i] print(" ".join([str(i) for i in cds]))
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] arr.sort() ans = arr[0] print(ans, end=" ") maa = [ans] i = 1 while i < m: ans += arr[i] print(ans, end=" ") maa.append(arr[i]) i += 1 while i < n: q = i % m maa[q] += arr[i] ans += maa[q] print(ans, end=" "...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR NUMBER...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
from sys import setrecursionlimit, stdin setrecursionlimit(10**7) def iin(): return int(stdin.readline()) def lin(): return list(map(int, stdin.readline().split())) def main(): n, m = lin() a = lin() a.sort() sa = [0] + a[:] for i in range(1, n + 1): sa[i] += sa[i - 1] ans...
EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) ans = [0] dp = [0] * n s = sorted(map(int, input().split())) for i in range(n): dp[i % m] += s[i] ans += [ans[-1] + dp[i % m]] print(*ans[1:])
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = [*map(int, input().split())] a.sort() ms = [[0] for _ in range(m)] for i in range(n): ms[i % m].append(ms[i % m][-1] + a[i]) for i in range(m): del ms[i][0] ans = [0] * n t = 1 while len(a): cs = 0 for _ in range(m): if not len(a): break c...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys input = sys.stdin.readline def main(): N, M = [int(x) for x in input().split()] A = [int(x) for x in input().split()] ans = [] days = 0 A_sorted = sorted(A) ans.append(A_sorted[0]) amari = [0] * M amari[0] += A_sorted[0] for i in range(1, N): x = ans[i - 1] ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() prefix = [0] * n prefix[0] = a[0] for i in range(1, n): prefix[i] = prefix[i - 1] + a[i] answers = [0] * n answers[0] = a[0] for i in range(1, m): answers[i] = answers[i - 1] + a[i] for i in range(m, n): answers[i] = prefix[i] + a...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys n, k = map(int, input().split()) input = sys.stdin.readline a = [int(x) for x in input().split()] dp = [(0) for i in range(n + 1)] a.sort() count = [] for i in range(k): p = [a[i]] c = 0 for j in range(i + k, n, k): p.append(p[c] + a[j]) c += 1 count.append(p) for i in range(...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_O...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = [] l = [0] * m s = 0 c = 0 for i in range(n): if i < m: s += a[i] l[i] = s else: s += a[i] c = l[i % m] l[i % m] = s + c ans.append(s + c) print(*ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) sugar = list(map(int, input().split())) sugar.sort() cummlativeSugarLevel = [] cSum = 0 ans = [] for i in range(m): cummlativeSugarLevel.append(0) ans.append(0) for i in sugar: cSum += i cummlativeSugarLevel.append(cSum) k = 0 for i in range(n): k += 1 j = k + m ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = input().split() n = int(n) m = int(m) l = [int(x) for x in input().split()] l.sort() l1 = [0] * n l1[0] = l[0] for i in range(1, n): if i - m >= 0: l[i] += l[i - m] for i in range(1, n): l1[i] = l1[i - 1] + l[i] for i in range(n): print(l1[i], end=" ")
ASSIGN 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 VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR BIN_OP VAR VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) s = [] mid = [0] * (n + 1) su = 0 for i in range(0, n): su += a[i] s.append(su) ans = [0] * (n + 1) for i in range(1, n + 1): t = a[i - 1] if i - 1 >= m: t += mid[i - 1 - m] mid[i - 1] = t t += ans[i - 1] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() acc = [[0] for _ in range(m)] for i in range(n): acc[i % m].append(acc[i % m][-1] + a[i]) ans = [0] * n cnt = 0 day = 1 for i in range(n): ans[-1] += a[n - 1 - i] * day cnt += 1 if cnt == m: day += 1 cnt = 0 cn...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) v = [0] * (n + 1) s = [0] * (n + 1) g = "" for i in range(1, n + 1): v[i] = v[i - 1] + a[i - 1] s[i] = s[i - m] + v[i] g += str(s[i]) + " " print(g)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
N, M = map(int, input().split()) sweets = sorted(list(map(int, input().split())), reverse=True) groupings = [[] for i in range(M)] for i, item in enumerate(sweets): groupings[i % M].append(item) cumsum = [[(0) for i in range(len(groupings[i]))] for i in range(M)] for t in range(M): cumsum[t][-1] = groupings[t][...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) candy = list(map(int, input().split())) candy.sort() sums = [0] * m for i in range(n): sums[i % m] += candy[i] answer = [0] * n d = 1 ser = 0 for i in range(n - 1, -1, -1): if ser == m: d += 1 ser = 0 answer[n - 1] += candy[i] * d ser += 1 for i in range(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def f(a): n = len(a) s = [a[0]] for i in range(1, n): s.append(s[-1] + a[i]) return s n, m = [int(s) for s in input().split()] a = sorted([0] + [int(s) for s in input().split()]) s1 = f(a) for i in range(m, n + 1): s1[i] += s1[i - m] for e in s1[1:]: print(e, end=" ")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def main(): n, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort(reverse=True) sums = [] visited = set() for i in range(1, n + 1): if i not in visited: total = 0 for j in range(i, n + 1, m): visited.add(j) ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys def rint(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline().rstrip("\n") def oint(): return int(input()) n, m = rint() a = list(rint()) a.sort() dd = [0] * n for i in range(n): if i >= m: dd[i] = dd[i - m] + a[i] else: dd[i] =...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def candy(l, m): l2 = sorted(l) sums = [0] * m sumstotal = [] currentsum = 0 for i in range(len(l)): sums[i % m] += l2[i] currentsum += sums[i % m] sumstotal += [currentsum] print(*sumstotal) n, m = map(int, input().split()) l = list(map(int, input().split())) candy(l, ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) A = list(map(int, input().split())) A = sorted(A) preA = [0] * (n + 1) for i in range(1, n + 1): preA[i] = preA[i - 1] + A[i - 1] res = [0] * (n + 1) for i in range(1, m + 1): res[i] = res[i - 1] + A[i - 1] for j in range(m): temp = res[j] for i in range(1, n // m + 1): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(j) for j in input().split()] a = [int(j) for j in input().split()] a.sort() pre = [0] * n pre[0] = a[0] for i in range(1, n): pre[i] += a[i] + pre[i - 1] x = [a[0]] * n for i in range(n): if i - m < 0: x[i] = pre[i] else: x[i] = pre[i] + x[i - m] print(" ".join(map(str, x)))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FOR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
firstRow = list(map(int, input().split(" "))) sweetList = list(map(int, input().split(" "))) numSweet = firstRow[0] maxSweet = firstRow[1] sweetList.sort() sweetSum = [] for i in range(210000): sweetSum.append(0) sweetListLen = len(sweetList) beforeSum = 0 sum = 0 for i in range(sweetListLen): quotient, remaind...
ASSIGN 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 NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
for _ in range(1): n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() ans = [] su = [a[0]] for i in range(1, m): su.append(a[i] + su[-1]) for j in range(m, n): su.append(su[-1] + a[j]) d = 1 for i in range(n): s = su[i] ...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
ii = lambda: int(input()) kk = lambda: map(int, input().split()) ll = lambda: list(kk()) n, m = kk() ls = sorted(kk()) i = 0 sums = [0] * m total = 0 while i < n: for k in range(m): if k + i == n: break sums[k] += ls[i + k] total += sums[k] print(total) i += m
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) arr = list(map(int, input().split())) arr = sorted(arr) sume = [(0) for i in range(n)] if n > 1: sume[0] = arr[0] for i in range(1, n): sume[i] = sume[i - 1] + arr[i] x = [] x = [(0) for i in range(n)] for i in range(m): x[i] = sume[i] for i in ra...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(s) for s in input().split()] arr = [int(s) for s in input().split()] arr.sort() sum = 0 running_sum = [0] * n for i in range(m): sum = sum + arr[i] running_sum[i] = sum for i in range(m, n): running_sum[i] = running_sum[i - 1] + arr[i] - arr[i - m] ans = [] for i in range(n): ans_i = running...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() p = 0 res = [] for j in range(n): p = p + a[j] if j < k: res.append(p) else: res.append(p + res[j - k]) print(" ".join(map(str, res)))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = [int(j) for j in input().split()] a.sort() prefix = [0] * n suffix = [0] * n cur_prefix = 0 for i in range(n): cur_prefix += a[i] prefix[i] = cur_prefix suffix[m - 1] = prefix[m - 1] for i in range(m, n): suffix[i] = prefix[i] - prefix[i - m] ans = [] for k in range(n): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) c = [a[0]] for i in range(1, len(a)): c.append(c[-1] + a[i]) for i in range(m, len(c)): c[i] = c[i] + c[i - m] print(*c)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def foo(n, m, l): l.sort() mem = [] somme = 0 suivant = [(0) for _ in range(m)] for k in range(n): somme += l[k] + suivant[k % m] suivant[k % m] += l[k] mem.append(somme) mot = "" for x in mem: mot += str(x) + " " print(mot) x = list(map(int, input().spl...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
from itertools import accumulate n, m = map(int, input().split()) arr1 = list(map(int, input().split())) arr1 = sorted(arr1) arr = list(accumulate(arr1)) dp = [0] * n ans = 0 for i in range(n): if i < m: dp[i] = arr[i] else: dp[i] = dp[i - m] + arr[i] print(*dp)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() pre = [0] * len(a) pre[0] = a[0] for i in range(1, len(pre)): pre[i] = pre[i - 1] + a[i] ans = [0] * n for i in range(m): ans[i] = pre[i] for i in range(m, n): ans[i] = a...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(_) for _ in input().split()] a = [int(__) for __ in input().split()] a.sort() l1 = [a[0]] for i in a[1:]: l1.append(l1[-1] + i) for i in range(m, n): l1[i] += l1[i - m] for i in l1: print(i, end=" ")
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) x = [0] * (n + 1) l = [] a.sort() for i in range(m): x[i] = a[i] for i in range(m, n): x[i] = a[i] + x[i - m] suma = 0 s = [0] * (n + 1) s[0] = a[0] for i in range(1, n): s[i] = a[i] + s[i - 1] i = n - 1 k = m c = 0 day = 1 suma = 0 j = i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys ip = lambda: sys.stdin.readline().rstrip() n, m = map(int, ip().split()) a = list(map(int, ip().split())) a.sort() pre = [] cs = 0 for i in a: cs += i pre.append(cs) for i in range(m, n): pre[i] += pre[i - m] print(*pre)
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR E...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() l = [[] for _ in range(m)] for i in range(n): l[i % m].append(a[i]) acc = [[0] for _ in range(m)] for i in range(m): for j in range(len(l[i])): acc[i].append(acc[i][-1] + l[i][j]) ans = 0 for i in range(n): ans += acc[i % ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() mat = [] for i in range(m): temp = [] curr = 0 for j in range(i, n, m): curr += arr[j] temp.append(curr) mat.append(temp) num = 0 curr = 0 i = -1 while num < n: if num % m == 0: i += 1 curr ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys n, m = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) a.sort() ans = [] arr = [0] * m pre = [a[0]] for i in range(1, n): pre.append(pre[i - 1] + a[i]) i, ind = 0, 0 while i < n: while ind < m and i < n: arr[ind] = pre[i] + arr[ind] ans.append(...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys input = lambda: sys.stdin.readline().strip("\r\n") n, m = map(int, input().split()) a = sorted(list(map(int, input().split()))) dp = [0] * n ans = 0 for i in range(n): ans += a[i] if i < m: dp[i] = ans else: dp[i] = ans + dp[i - m] print(*dp)
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() for i in range(1, n): arr[i] += arr[i - 1] ans = [0] * n for j in range(m): ans[j] = arr[j] k = j + m while k < n: ans[k] = ans[k - m] + arr[k] k += m print(*ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a = sorted(a) s = [] summ = 0 for i in range(m): s.append(summ + a[i]) summ += a[i] for i in range(m, n): s.append(summ + s[i - m] + a[i]) summ += a[i] for x in s: print(x, end=" ") print("")
ASSIGN 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) array = list(map(int, input().split())) array.sort() ans = [0] s = 0 for i in range(n): s += array[i] if i - m + 1 >= 0: ans.append(ans[i - m + 1] + s) else: ans.append(s) print(*ans[1:])
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys def input(): return sys.stdin.readline().rstrip() [n, m] = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() s = [0] * (n + 1) ans = [0] * (n + 1) for i in range(1, n + 1): s[i] = s[i - 1] + a[i - 1] if i - m >= 0: ans[i] = s[i] + ans[i - m] else: ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(p) for p in input().split()] arr = [int(p) for p in input().split()] a = sorted(arr) preSum = a.copy() for i in range(1, n): preSum[i] += preSum[i - 1] ans = [0] * n ans[0] = a[0] for i in range(1, m): ans[i] = ans[i - 1] + a[i] for i in range(m, n): ans[i] = ans[i - m] + preSum[i] print(*ans)
ASSIGN 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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() dp = [[0, 0] for _ in range(n)] dp[0][0] = a[0] arr = [] for i in range(1, n): dp[i][0] = a[i] + dp[i - 1][0] if i - m >= 0: dp[i][1] = dp[i - m][0] + dp[i - m][...
IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER BI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def readint(): return int(input()) def readlistint(): return list(map(int, input().split())) def readgridint(rows): grid = [] for idx in range(rows): col = list(map(int, input().split())) grid.append(col) return grid def printlistint(lst): print(" ".join(map(str, lst))) d...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) l = list(map(int, input().split())) l.sort() ps = [0] ll = [[0] for i in range(m)] for i in range(0, n, m): for j in range(i, min(n, i + m)): ll[j - i].append(ll[j - i][-1] + l[j]) ans = 0 for i in range(n): u = i // m r = (i + 1) % m ans = ans + ll[r - 1][u + 1]...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CAL...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = sorted(list(map(int, input().split()))) s = 0 for i in range(len(a)): if i < m: s += a[i] print(s, end=" ") continue a[i] += a[i - m] s += a[i] print(s, end=" ") print()
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING EX...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def solver(prefix, n): ans = [0] * n for i in range(n): if i < m: ans[i] += prefix[i] else: ans[i] = ans[i - m] + prefix[i] return ans n, m = map(int, input().split()) arr = list(map(int, input().split())) arr.sort() prefix = [arr[0]] for i in range(1, n): prefi...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR N...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys readline = sys.stdin.readline mr = lambda: map(int, readline().split()) Ans = [] n, m = mr() tmp = list(mr()) tmp.sort() pref = [] for i in range(n): if i >= m: pref.append(tmp[i] + pref[i - m]) else: pref.append(tmp[i]) tp = 0 for i in range(n): tp += pref[i] Ans.append(tp) ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) ans = [a[0]] pref = [a[0]] for q in range(1, m): ans.append(ans[-1] + a[q]) pref.append(a[q]) for q in range(m, n): pref[q % m] += a[q] ans.append(ans[-1] + pref[q % m]) print(*ans)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR F...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort(reverse=True) x = list() x.append(0) hvost = list() for i in range(m): hvost.append(0) i = 1 while i < n + 1: if i <= m: x.append(a[-i] + x[-1]) else: hvost[i % m] += a[-i + m] x.append(a[-i] + x[-1] + ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() f = [0] * 1000000 sum = [0] * 1000000 for i in range(n): sum[i] = sum[i - 1] + a[i] for i in range(n): f[i] = f[i - m] + sum[i] print(f[i], end=" ")
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys def sugar(a, n, m): a.sort() Sa = [a[0]] for i in range(1, n): Sa.append(Sa[-1] + a[i]) d = [None] * n for i in range(m): d[i] = Sa[i] for i in range(m, n): d[i] = d[i - m] + Sa[i] return d reader = (map(int, s.split()) for s in sys.stdin) n, m = next(r...
IMPORT FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() b = [] curr = 0 for i in a: curr += i b.append(curr) k = [] for i in range(min(m, n)): k.append(b[i]) print(b[i], end=" ") for i in range(min(m, n), n): k[i % m] += b[i] print(k[i % m], end=" ")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CAL...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) pen = list(map(int, input().split())) wyn = [0] * n pen.sort() dupa = [0] * n for i in range(m): dupa[i] = pen[i] for i in range(m, n): dupa[i] = dupa[i - m] + pen[i] wyn[0] = dupa[0] for i in range(1, n): wyn[i] = wyn[i - 1] + dupa[i] print(*wyn)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR B...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def oneLineArrayPrint(arr): print(" ".join([str(x) for x in arr])) n, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a.sort(reverse=True) suffixsum = [(0) for _ in range(n)] for i in range(n - 1, -1, -1): suffixsum[i] = a[i] if i + m < n: suffixsum[i] += suffixsum[i + ...
FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
from sys import stdin n, m = map(int, input().split()) treats = list(map(int, input().split())) treats.sort() prefix = [treats[0]] + [(0) for i in range(n - 1)] for i in range(1, n): prefix[i] = prefix[i - 1] + treats[i] best = [(0) for i in range(n)] for i in range(n): if i < m: best[i] = prefix[i] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMB...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = [int(i) for i in input().split()] a.sort() cum = [(0) for _ in range(n)] dp1 = [(0) for _ in range(n)] dp2 = [(0) for _ in range(n)] cum[0] = a[0] dp1[0] = a[0] dp2[0] = a[0] for i in range(1, n): cum[i] = a[i] + cum[i - 1] dp1[i] = cum[i] if i - m >= 0: dp1[i] -...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) b = [a[0]] for i in range(1, n): b.append(b[-1] + a[i]) ans = [0] * m + b[:m] for i in range(m, n): ans.append(b[i] + b[i - m] + ans[i - m]) ans = ans[m : m + n] print(*ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR VAR VAR FOR VAR FUNC_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(s) for s in input().split()] a = [int(s) for s in input().split()] a.sort() dp = [0] * (n + 1) prf = 0 for k in range(1, n + 1): prf += a[k - 1] dp[k] = prf if k > m: dp[k] += dp[k - m] print(dp[k], end=" ") print()
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR BI...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() prefix = [a[0]] for i in range(1, n): prefix.append(prefix[i - 1] + a[i]) d = [0] * n for j in range(n): if j < m: d[j] = prefix[j] else: d[j] = prefix[j - m] + d[j - m] + prefix[j] - prefix[j - m] print(" "....
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(i) for i in input().split()] arr = [int(i) for i in input().split()] arr.sort() ans = 0 dp = [0] * n for i in range(n): if i - m >= 0: dp[i] = arr[i] + dp[i - m] else: dp[i] = arr[i] mul = 1 rem = m temp = 0 for i in range(n - 1, -1, -1): temp += arr[i] rem -= 1 if rem ==...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) list1 = list(map(int, input().split())) list1.sort() sum1 = [list1[0]] for i in range(1, len(list1)): sum1.append(list1[i] + sum1[i - 1]) sum1.reverse() ans = list() for i in range(len(sum1)): ans.append(0) j = 0 i = len(sum1) - 1 while i >= 0: p = sum1[i] if j - m >= 0:...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() ans = 0 j = 0 cnt = [(0) for i in range(m)] for i in range(len(a)): cnt[j] += a[i] ans += cnt[j] j = (j + 1) % m print(ans, end=" ")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMB...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = tuple(map(int, input().split())) arr = list(map(int, input().split())) arr.sort() prefix_sum = [0] * n prefix_sum[0] = arr[0] for i in range(1, n): prefix_sum[i] = prefix_sum[i - 1] + arr[i] ans = [0] * (n + 1) for k in range(1, m + 1): ans[k] = prefix_sum[k - 1] for k in range(m + 1, n + 1): ans[k] ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) lis = sorted(map(int, input().split())) pre = [0] * n + [0] * m for i in range(m, n + m): pre[i] = pre[i - 1] + lis[i - m] ans = [] for i in range(m, n + m): pre[i] = pre[i] + pre[i - m] print(*pre[m:])
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = sorted(map(int, input().split())) sums = [0] * n ans = [0] * n for i in range(m): sums[i] = ans[i] = a[i] for i in range(m, n): sums[i] = sums[i - m] + a[i] ans[i] = ans[i - m] + sums[i] for i in range(n - 1): ans[i + 1] += ans[i] for i in reversed(range(m, n)): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def solution(x, m): x.sort() ans = [] res = 0 slice_add = [0] * m for k in range(len(x)): slice_add[k % m] += x[k] res += slice_add[k % m] ans.append(res) return ans n, m = map(int, input().split()) x = list(map(int, input().split())) print(" ".join(map(str, solution(x,...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return list(map(int, minp().split())) def solve(): n, m = mints() a = list(mints()) a.sort() rr = [0] * n c = [0] * m ss = 0 for i in range(1, n + 1): ss += a[i ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMB...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = sorted(map(int, input().split())) b = [0] * n for i in range(n): b[i] = a[i] if i - m >= 0: b[i] += b[i - m] + a[i - m] a[i] += a[i - m] v = [] s = 0 for i in range(n): s += b[i] if i - m >= 0: s -= b[i - m] v += (s,) print(" ".join(map(st...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a.sort() val = [0] * 200001 pre = [0] * 200001 pre[0] = a[0] for i in range(1, n): pre[i] = pre[i - 1] + a[i] val[0] = a[0] for i in range(1, m): val[i] = val[i - 1] + a[i] for i in range(m, n): val[i] = pre[i] - pre[i - m] v...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import itertools as itt f = lambda: list(map(int, input().split())) n, max_sweet_per_days = f() sweets = f() sweets.sort() the_sum = list(itt.accumulate(sweets[:max_sweet_per_days])) sweet_penalty = the_sum.copy() current_day = 1 for k in range(max_sweet_per_days, n): the_sum.append(the_sum[-1] + sweets[k]) da...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) cur_sum = 0 ans = [(0) for i in range(n)] for last_taken in range(n): cur_sum += a[last_taken] ans[last_taken] = cur_sum if last_taken >= m: ans[last_taken] += ans[last_taken - m] print(" ".join(map(str, ans)))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline n, m = [int(item) for item in input().split()] sweets = [int(item) for item in input().split()] sweets.sort() cumsum_mod = [0] * n for delta in range(m): cumsum_mod[delta] = sweets[delta] i = 1 while delta + i * m < n: current = del...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) l = sorted(list(map(int, input().split()))) dp = [(0) for i in range(n)] k = [(0) for i in range(m)] dp[0] = l[0] k[0] = l[0] count = 0 for i in range(1, m): dp[i] = dp[i - 1] + l[i] k[i] = l[i] for i in range(m, n): if count == m: count = 0 dp[i] = l[i] + dp[i -...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMB...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = [0] + list(map(int, input().split())) a.sort() y = [1] for i in range(1, n + 1): a[i] = a[i] + a[i - 1] for i in range(m, n + 1): a[i] = a[i] + a[i - m] for i in range(1, len(a)): print(a[i], end=" ")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) a = [int(i) for i in input().split()] a.sort() indexes = {} for ind in range(n): if ind % m not in indexes: indexes[ind % m] = [a[ind]] else: indexes[ind % m].append(indexes[ind % m][-1] + a[ind]) total_sum = 0 local_m = 1 day = 1 for num in a[::-1]: if local...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = [int(x) for x in input().split()] X = sorted([int(x) for x in input().split()]) s = 0 R = [0] * n P = [0] * n for i in range(m): s += X[i] R[i] = s P[i] = X[i] for i in range(m, n): P[i] = X[i] + P[i - m] R[i] = R[i - 1] + P[i - m] + X[i] print(" ".join([str(x) for x in R]))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR ...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) ar = list(map(int, input().split())) ar.sort() dp = [0] * n dp[0] = ar[0] for i in range(1, n): if i >= m: dp[i] = ar[i] + dp[i - m] else: dp[i] = ar[i] s = 0 for i in range(n): if i >= m: s += dp[i - m] + ar[i] print(s, end=" ") else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VA...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = input().split() tot = 0 val = [int(x) for x in input().split()] val.sort() ans = [None] * int(n) for i in range(int(n)): tot = tot + val[i] ans[i] = tot if i >= int(m): ans[i] = ans[i] + ans[i - int(m)] print(ans[i], "\n" if i == int(n) - 1 else " ")
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR V...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
n, m = map(int, input().split()) arr = sorted(list(map(int, input().split()))) ad = [(0) for z in range(m)] ans = 0 i = 0 k = 0 while i < n: ad[k] += arr[i] ans += ad[k] k += 1 if k == m: k = 0 i += 1 print(ans, end=" ")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR NU...
Tsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$. Yui loves sweets, but she can eat at most $m$ sweets each day for health reasons. Days are $1$-indexed (numbered $1, 2, 3, \ldots$). Eating t...
def sorting(arr): hehe = [0] * 200001 for i in range(len(arr)): hehe[arr[i]] += 1 ans = [] for i in range(200001): ans += [i] * hehe[i] return ans n, m = list(map(int, input().split())) arr = list(map(int, input().split())) arr = sorting(arr) sums = [0] * m total = 0 ans = [] f...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP LIST VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...