description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k, z_max = map(int, input().split()) a = [int(item) for item in input().split()] ans = 0 for z in range(min(z_max + 1, (k + 1) // 2 + 1)): left = z right = 1 + k - z * 2 ret = sum(a[:right]) max...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) f = list(map(int, input().split())) g = [] for i in range(k): g.append(f[i] + f[i + 1]) res = sum(f[: k + 1]) for i in range(1, z + 1): index = k + 1 - 2 * i if index < 0: break tmp = su...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = list(map(int, input().split())) arr = list(map(int, input().split())) prefixsum = [arr[0]] for j in range(1, n): prefixsum.append(prefixsum[-1] + arr[j]) lis = [] for j in range(k - 2): lis.append(arr[j] + arr[j + 1]) array = [] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
(q,) = map(int, input().split()) for _ in range(q): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) sa = [] pa = [] l = 0 for i, c in enumerate(arr): l += c sa.append(l) if i: pa.append(c + arr[i - 1]) if len(pa) > 1: ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
tt = int(input()) for _ in range(tt): n, k, z = [int(x) for x in input().split(" ")] arr = [int(x) for x in input().split(" ")] m, ans, y = 0, 0, 0 for t in range(z + 1): p = k - 2 * t m, s = 0, 0 if p < 0: continue for i in range(p + 1): s += arr[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) b = [] for i in range(n - 1): b.append(a[i] + a[i + 1]) mx = 0 c = [] for i in b: mx = max(mx, i) c.append(mx) total ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, l = map(int, input().split()) lissht = list(map(int, input().split())) pairsum = [] for j in range(k): pairsum.append(lissht[j] + lissht[j + 1]) max_k_sum = 0 ans = 0 su = 0 for ki in range(l + 1): su = 0 ma = sum(lissht[:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) sum = [] two = [] for i in range(n): if i == 0: sum.append(a[i]) two.append(0) else: sum.append(sum[i - 1] + a[i]) two.append(ma...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EX...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
inp = lambda: map(int, input().split(" ")) (t,) = inp() for _ in range(t): n, k, z = inp() a = list(inp()) max_index = 0 max_pair = 0 max_sum = 0 lin_sum = a[0] for i in range(k): curr_pair = a[i] + a[i + 1] max_pair = max(max_pair, curr_pair) lin_sum += a[i + 1] ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_O...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) nei = list(a1 + a2 for a1, a2 in zip(a, a[1:])) best = 0 for lefts in range(z + 1): rights = k - lefts for final_left in [False, True]: if rights < 1 + lefts - fina...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys for _ in range(int(sys.stdin.readline())): n, k, z = map(int, sys.stdin.readline().split()) a = [int(i) for i in sys.stdin.readline().split()] prefix_sums = [a[0]] for a_i in a[1:]: prefix_sums.append(prefix_sums[-1] + a_i) if z == 0: print(sum(a[: k + 1])) else: ...
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ def gift(): for _ in range(t): n, k, z = list(map(int, input().split())) arr = list(map(int, input().split())) if z == 0: yield sum(arr[: k + 1]) else: plainsum = sum(arr[: k + 1]) ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def solve(n, k, z, a): answ = sum(a[: k + 1]) for t in range(z + 1): max_sum = 0 s = 0 for i in range(k - 2 * t + 1): s1 = 0 if i + 1 >= len(a) else a[i + 1] + a[i] if s1 > max_sum: max_sum = s1 s += a[i] if max_sum * t + s > an...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
N = int(input().strip()) for i in range(N): n, k, Z = map(int, input().strip().split()) score_list = list(map(int, input().strip().split())) compare = [(score_list[i] + score_list[i + 1]) for i in range(k)] result = [0, 0, 0, 0, 0, 0] if k % 2 == 1: for z in range(min(6, int((k + 1) / 2))): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) if k <= 1: ans = sum(a[: k + 1]) else: i = (k + 1) % 2 if i == 0: i = 2 x = sum(a[:i]) if (k + 1) % 2 == 0: m = a[0] + a[1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = input().split() n = int(n) k = int(k) z = int(z) diyo = list(map(int, input().split())) adjesentsum = [diyo[0]] for index1 in range(1, k + 1): adjesentsum.append(adjesentsum[-1] + diyo[index1]) T_pair = [] for index1 in range(k): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BI...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys readline = sys.stdin.readline def solve(): N, K, Z = map(int, readline().split()) A = list(map(int, readline().split())) dp = [([0] * (2 * (Z + 1))) for i in range(N)] dp[0][0] = A[0] for i in range(1, N): dp[i][0] = dp[i - 1][0] + A[i] for j in range(1, Z + 1): for...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import stdin, stdout t = int(stdin.readline()) for _ in range(t): n, k, z = map(int, stdin.readline().split()) a_a = list(map(int, stdin.readline().split())) preSum = [0] for i in range(len(a_a)): preSum.append(a_a[i] + preSum[i]) ans = a_a[0] for i in range(1, len(a_a)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a * b // gcd(a, b) def power(a, k, m): res = 1 while k > 0: if k % 2 == 1: res = res * a % m a = a * a % m k = k // 2 return res % m def solution(): n, k, z = map(i...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
T = int(input()) for _ in range(0, T): n, k, z = map(int, input().split()) s = [int(x) for x in input().split()] c = [] for i in range(0, z + 1): if k - 2 * i >= 0: ct = s[0] for j in range(1, k - 2 * i + 1): ct += s[j] mx = 0 for j...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(0, t): s = input().split(" ") n = int(s[0]) k = int(s[1]) z = int(s[2]) a = list(map(int, input().split())) dyn = {} dyn[0, 0, z] = a[0] ans = 0 for j in range(0, k): new_dyn = {} for (i, l, _z), val in dyn.items(): if i > 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) mx = 0 for i in range(z + 1): h = k - i * 2 if h < 0: continue tmp = 0 for j in range(1, h + 1): two = arr[j - 1] + arr[j] if tmp <=...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for you in range(t): l = input().split() n = int(l[0]) k = int(l[1]) z = int(l[2]) l = input().split() li = [int(i) for i in l] maxa = 0 for i in range(z + 1): if k - 2 * i <= 0: continue sumi = li[0] maxpairsum = 0 for j in ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 NUMBER FOR VAR FUNC_CALL VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, K, z = map(int, input().split()) a = list(map(int, input().split())) ans = 0 mx1 = 0 for j in range(z + 1): v = a[0] mx1 = 0 aj = 0 for k in range(1, K - 2 * j + 1): v = v + a[k] sum = a[k] + a[k - 1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) m = [] for i in range(1, k + 1): m.append(a[i] + a[i - 1]) m.append(-1) ma = -1 sm = 0 max_ans = 0 for i in range(k + 1): ma = max(ma, m[i]) sm += a[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUN...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline aaaa = list() for kek in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) left = list() for i in range(1, n): left.append((a[i] + a[i - 1], i)) left.sort(key=lambda x: (-x[0], x[1])) answer = 0 for x i...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) cnt = 0 while cnt < t: cnt += 1 n, k, z = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [0] * n b[0] = a[0] for i in range(1, n): b[i] = b[i - 1] + a[i] res = 0 count = 0 tmp = 0 for i in range(1, min(k + 1, n)): curr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_O...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) l = list(map(int, input().split())) pref = l[:] for i in range(1, n): pref[i] += pref[i - 1] ans = 0 for i in range(1, n): tot = pref[i - 1] rem = k - i + 1 loop = min(2 * z, rem - rem % 2) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split(" ")) a = list(map(int, input().split(" "))) m = 0 for left in range(z + 1): if k - 2 * left + 1 >= 0: temp = 0 for j in range(k - 2 * left + 1): if j + 1 < n and a[j] + a[j + 1] > temp: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER AS...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) x = sum(a[: k + 1]) if z == 0: print(x) continue s = [0] * (z + 1) s[0] = x for i in range(1, z + 1): s[i] = s[i - 1] - a[k - 2 * i + 1] - a[k - 2 * i + 2] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NU...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) sm = [0] * n best = [0] * n for i in range(n): sm[i] = (0 if i == 0 else sm[i - 1]) + a[i] for i in range(1, n): cur = a[i] + a[i - 1] best[i] = max(best[i - 1], cu...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) l = list(map(int, input().split())) dp = [(0) for i in range(k + 1)] dp[0] = l[0] for i in range(1, k + 1): dp[i] = l[i] + dp[i - 1] ans = dp[k] for i in range(k - 1): r = k - i r1 = r // 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) pre = [0] * n pre[0] = arr[0] for i in range(1, n): pre[i] = pre[i - 1] + arr[i] ans = 0 for i in range(1, k + 1): mv = min(z, (k - i + 1) // 2) temp = pre[k - 2 * ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) d = 0 s = a[0] v = 0 for i in range(1, k + 1): s += a[i] d = max(d, a[i - 1] + a[i]) if i % 2 == k % 2: x = (k - i) // 2 if x <= z: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
OK = lambda: map(int, input().split()) (t,) = OK() for _ in [0] * t: n, m, z = OK() a = (*OK(),) print( max( sum(a[: m + 1 - 2 * i]) + i * max(map(sum, zip(a, a[1 : m + 2 - (2 * i or m)]))) for i in range(min(z, m // 2) + 1) ) )
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from itertools import accumulate from sys import gettrace, stdin if gettrace(): inputi = input else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def solve(): n, k, z = map(int, inputi().split()) aa = [int(a) for a in inputi().split()][: k + ...
IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF 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 BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) b = a[: k + 1] score = sum(b) y = len(b) c = [] for i in range(0, k): c.append(a[i] + a[i + 1]) for i in range(1, z + 1): x = y - 2 * i if x < 0: brea...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EX...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys T = int(sys.stdin.readline().strip()) for t in range(0, T): n, k, z = list(map(int, sys.stdin.readline().strip().split())) a = list(map(int, sys.stdin.readline().strip().split())) b = [0] * n c = [0] * n c[0] = a[0] d = [0] * n d[0] = a[0] + a[1] for i in range(1, n): ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR A...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for t in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) s = [a[0]] b = [0] c = a[0] for i in range(1, k + 1): c += a[i] s.append(c) b.append(max(b[i - 1], a[i] + a[i - 1])) m = 1 k -= 2 while m <= z and k >= 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_C...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for i in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split()))[: k + 1] length = k + 1 sums = [(a[i] + a[i + 1]) for i in range(len(a) - 1)] maxs = [sum(a)] try: for i in range(1, 1 + z): a.pop() a.pop() maxs.appe...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMB...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def put(): return map(int, input().split()) n = int(input()) for _ in range(n): n, k, z = put() l = list(put()) ans, k, dp = 0, k + 1, [] for i in range(k - 1): dp.append(l[i] + l[i + 1]) for i in range(z + 1): if k - 2 * i > 0: ans = max(ans, sum(l[: k - 2 * i]) + ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP VAR NUMBER LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) lis = list(map(int, input().split())) sul = [] su = 0 for i in lis: su += i sul.append(su) ma = 0 for i in range(1, k + 1): tu = k - i lu = z su = sul[i] if tu >= 2 * z: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline t = int(input()) for ii in range(t): n, k, z = map(int, input().split()) a = [int(i) for i in input().split() if i != "\n"] pref = [a[0]] for i in range(1, n): pref.append(pref[-1] + a[i]) ans = [pref[k]] left = 0 for i in range(k - 1, 0, -1): ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) pairSum = [[i, i + 1] for i in range(n - 1)] pairSum.sort(key=lambda x: arr[x[0]] + arr[x[1]]) sumUptoK = sum(arr[: k + 1]) ans = sumUptoK for leftMoves in range(1, z + 1): if k < ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR F...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) l = list(map(int, input().split())) l1 = [] c = 0 for j in l: c += j l1.append(c) ans = l1[k] l2 = [] for j in range(n - 1): l2.append(l[j] + l[j + 1]) for j in range(z + 1): if k ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) dp = [0] for item in arr: dp.append(item + dp[-1]) ans = dp[k + 1] if not z: print(ans) ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUM...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
cases = int(input()) for t in range(cases): n, k, z = list(map(int, input().split())) a = list(map(int, input().split())) b = [0] * (n + 1) for i in range(n): b[i + 1] = b[i] + a[i] s = 0 for i in range(1, k + 1): s1 = b[i + 1] left = k - i if left / 2 > z: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline for nt in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) a = a[0 : k + 1] n = len(a) pref = [a[0]] for i in range(1, n): pref.append(pref[-1] + a[i]) maxx = [a[0]] left = [k] start = [0] ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NU...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from itertools import accumulate def max_score(a, n, k, z): combined = [(a[i] + a[i + 1]) for i in range(k - 1)] cumsum = list(accumulate(a)) max_so_far = cumsum[k] for i in range(z + 1): if k - 2 * i >= 0: mx, s = 0, 0 for j in range(k - 2 * i + 1): if ...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = [int(s) for s in input().split()] arr = [int(s) for s in input().split()] pref = [0] * (n + 1) for i in range(n): pref[i + 1] = pref[i] + arr[i] ans = pref[k + 1] z = min(z, k // 2) for t in range(1, z + 1): cand = pref[k + 1 - 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) b = [a[0]] * n c = [0] * n d = [0] * n m = a[0] + a[1] for j in range(1, k + 1): b[j] = b[j - 1] + a[j] c[j] = a[j - 1] + a[j] if c[j] >= m: d[j] = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def mi(): return map(int, input().split()) def ii(): return int(input()) def li(): return list(map(int, input().split())) def si(): return input().split() t = ii() for _ in range(t): n, k, z = mi() a = li() psum = [a[0]] for i in range(1, k + 1): psum.append(psum[-1] + a[...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def f(a, s, kk): suma = sum(a) n = len(a) sol = suma for k in range(1, kk + 1): if n - 2 * k + 1 < 0: break ssol = suma - sum(a[n - 2 * k + 1 :]) ssol += a[n - 2 * k - 1] for i in s: if i[1] <= n - 2 * k - 1: ssol += i[0] * (k - 1) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def solve(a, n, k, z): pre = [0] * n pre[0] = a[0] for i in range(0, n): pre[i] = a[i] + pre[i - 1] ans = pre[k] k -= 1 for i in range(1, n): if k == 0: break q = min(k, z * 2) ans = max( ans, (a[i] + a[i - 1]) * (q // 2) + a[i - 1] * (q % ...
FUNC_DEF 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 VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline T = int(input()) def psum(l): res = [0] * (len(l) + 1) for i in range(1, len(res)): res[i] = res[i - 1] + l[i - 1] return res for t in range(T): N, K, Z = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] pa = psum(A) a...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [([c] * b) for i in range(a)] def list3d(a, b, c, d): return [[([d] * c) for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[([e] * d) for j in range(c)...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) p = [a[0]] for i in range(1, n): p.append(p[-1] + a[i]) s = p[k] for i in range(1, k + 1): k -= 1 r = k cs = 0 cz = z m = 0 while r > 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) while t: n, k, z = map(int, input().split()) a = list(map(int, input().split())) psum = [0] * n total = [a[0]] * n score = 0 mx = 0 for i in range(0, n - 1): psum[i] = max(psum[i - 1], a[i] + a[i + 1]) for i in range(1, n): total[i] = total[i - 1] + a[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) scores = list(map(int, input().split())) maxscore = 0 bestpair = [scores[0] + scores[1], 1, scores[0] + scores[1]] trngscore = 0 score = scores[0] for j in range(1, k + 1 - 2 * z): score += scores[j] if s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys def solve(A, k, z): DEBUG = False n = len(A) cum = [0] * n cum[0] = A[0] for i in range(1, n): cum[i] = cum[i - 1] + A[i] if DEBUG: print("CUM:", cum) BEST_TWO_LEFT = [0] * (k + 1) for i in range(1, min(k, n - 2)): TWO = A[i - 1] + A[i] BEST_T...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 IF VAR EXPR FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NU...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) max2sum = [0, 0, 0, 0, 0, 0] pos = [-2] * 6 ans = [arr[0]] * 6 for i in range(k): if arr[i] + arr[i + 1] > max2sum[0]: max2sum[0] = arr[i] + arr[i + 1] po...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBE...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) lis = list(map(int, input().split())) lis = lis[: k + 1][::-1] pre = [0] * (k + 5) pre[0] = lis[0] for i in range(k, -1, -1): pre[i] = pre[i + 1] + lis[i] tmp = ans = pre[0] for i in range(1, k): ss = lis[i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline for _ in range(int(input())): n, k, z = map(int, input().split()) ar = list(map(int, input().split())) li = [ar[0]] for i in range(1, n): li.append(ar[i] + li[-1]) ans = li[k] ind = k + 1 zz = z while z: rev = zz - z + 1 ind ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import stdin tt = int(stdin.readline()) for loop in range(tt): n, k, z = map(int, stdin.readline().split()) a = list(map(int, stdin.readline().split())) dp = [[0, 0] for i in range(n)] ans = 0 for i in range(n): if i == 0: dp[i][0] = a[0] continue dp...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR NU...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) a = [int(v) for v in input().split()] m = 0 y = z q = min(k, n - 1) p = 0 if z >= 1: dp = [0] for j in range(0, n): dp.append(dp[-1] + a[j]) for j in range(0, min(k, n - 1)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR LIST NUMBER FO...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for case in range(int(input())): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) summ = [0] * n adj = [0] * n for i in range(n): summ[i] = summ[i - 1] + arr[i] if i >= 1: adj[i] = max(adj[i - 1], arr[i] + arr[i - 1]) z = min(z, k // 2) an...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = [int(x) for x in input().split()] b = [0] * n c = [0] * n c[0] = a[0] for i in range(1, n): b[i] = max(b[i - 1], a[i] + a[i - 1]) c[i] = a[i] + c[i - 1] ans = 0 for i in range(z + 1): if k...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for test in range(int(input())): n, k, z = map(int, input("").split()) A = list(map(int, input("").split())) ans = 0 prefix = [A[0]] for i in range(1, n): prefix.append(prefix[-1] + A[i]) if z == 0: print(prefix[k]) continue best = 0 ans = 0 i = 0 temp = k...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys LI = lambda: list(map(int, sys.stdin.readline().strip("\n").split())) MI = lambda: map(int, sys.stdin.readline().strip("\n").split()) SI = lambda: sys.stdin.readline().strip("\n") II = lambda: int(sys.stdin.readline().strip("\n")) for _ in range(II()): n, k, z = MI() a = LI() ans = 0 for i i...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_C...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k, z = list(map(int, input().split())) n = min(n, k + 1) arr = list(map(int, input().split())) arr = arr[:n] b_best = 0 for i in range(z + 1): if k + 1 - 2 * i > 1: temp = arr[: k + 1 - 2 * i] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def max_backsteps(index, moves, z): return min((moves - index) // 2, z) def calc(a, z): partial_sums = list() s = 0 for item in a: s += item partial_sums.append(s) moves = len(a) - 1 best_sum = partial_sums[-1] for i in range(len(a) - 2): backsteps = max_backsteps(i...
FUNC_DEF RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) while t: nkz = list(map(int, input().rstrip().split())) n = nkz[0] k = nkz[1] z = nkz[2] a = list(map(int, input().rstrip().split())) res = 0 for left in range(min(z + 1, k // 2 + 1)): ans = 0 max_pair = 0 for i in range(k + 1 - 2 * left): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
num = int(input()) result = [] for i in range(num): n, k, z = map(int, input().split()) l = list(map(int, input().split())) psum = [] s = 0 for i in range(n): s += l[i] psum.append(s) if z == 0: result.append(psum[k]) else: asum = [] for i in range(n -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EX...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for q in range(int(input())): INF = 10**20 n, k, z = map(int, input().split()) line = list(map(int, input().split())) dp = [([INF] * (z + 1)) for i in range(k + 2)] dp[0][0] = line[0] ans = line[0] for i in range(1, k + 1): for j in range(z + 1): if i + 2 * j <= k: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
q = int(input()) for _ in range(q): n, k, z = map(int, input().split()) A = list(map(int, input().split())) S = [0] MZ = [0] for i in range(n): S.append(S[-1] + A[i]) if i < n - 1: MZ.append(max(MZ[-1], A[i + 1] + A[i])) S = S[1:] MZ = MZ[1:] MZ.append(0) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR BIN...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import stdin input = stdin.readline for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) mini = sum(a[: k + 1]) acum = [a[0]] for i in range(1, k + 1): acum.append(acum[i - 1] + a[i]) j = 1 while k: ans = acum[j] ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR F...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline t = int(input()) for tests in range(t): n, k, z = map(int, input().split()) A = list(map(int, input().split())) ANS = sum(A[: k + 1]) for gc in range(1, z + 1): MAX = 0 if k + 1 - gc * 2 <= 0: break for i in range(k - 2 * gc + 1)...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) pref = [0] * n pref[0] = a[0] ans = a[0] for i in range(1, n): pref[i] = pref[i - 1] + a[i] for i in range(1, n): if k - i < 0: continue r = k - i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) l = list(map(int, input().split())) p = l[:] for i in range(1, n): p[i] += p[i - 1] ans = p[k] for i in range(n - 1): for j in range(z): tempans = p[i + 1] if i + 1 + 2 * (j + 1) > k: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR V...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.buffer.readline for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) pfsums = [(0) for i in range(n)] pfsums[0] = a[0] for i in range(1, n): pfsums[i] = a[i] + pfsums[i - 1] pfMaxPair = [(0) for i in range(n)]...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def solve(a, k, z): r = sum(a[:k]) if z > 0: r += max(a[i] + a[i + 1] for i in range(k)) * z return r for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) print(max(solve(a, k - z * 2 + 1, z) for z in range(z + 1) if z * 2 <= k))
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL F...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for x in range(int(input())): n, k, z = map(int, input().split()) s = list(map(int, input().split())) pref = [(0) for _ in range(n + 1)] for i in range(len(s)): pref[i + 1] = pref[i] + s[i] maxx = s[0] for i in range(1, k + 1): now = pref[i + 1] if k - i < 2 * z: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input().split()[0]) for case in range(t): n, k, z = map(int, input().split()) arr = list(map(int, input().split())) ans = 0 for i in range(k + 1): ans += arr[i] if z == 0: print(ans) continue bestGain = 0 for i in range(k): currGain = 0 if i + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASS...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import * input = stdin.readline for _ in range(int(input())): n, k, z = map(int, input().split()) a = list(map(int, input().split())) mx = 0 d = [0] for i in range(1, n): mx = max(mx, a[i] + a[i - 1]) d.append(mx) p = [] sn = 0 for i in range(n): sn += a...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_O...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
(T,) = map(int, input().split()) for _ in range(T): N, K, Z = map(int, input().split()) X = list(map(int, input().split())) dp = [([0] * (Z + 1)) for _ in range(N + 2)] dp2 = [([0] * (Z + 1)) for _ in range(N + 2)] for i in range(Z + 1): for j in range(1, N + 1): dp[j][i] = max(d...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) def main(): t = int(input()) for _ in range(t): N, K, Z = map(int, input().split()) A = [0] + list(map(int, input().split())) dp = [([0] * (N + 1)) for i in range(Z + 1)] for j in range(1, N + 1): d...
IMPORT ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
I = lambda: map(int, input().split()) (t,) = I() for _ in [0] * t: n, k, z = I() (*s,) = I() p = [0] for i in s: p += (p[-1] + i,) i = A = 0 while k: x = min(k // 2, z) y = min((k + 1) // 2, z + 1) A = max( A, p[i + 1] + x * s[i...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FU...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import stdin input = stdin.readline t = int(input()) for _ in range(t): n, k, z = list(map(int, input().rstrip().split(" "))) arr = list(map(int, input().rstrip().split(" "))) prefixArr = [0] * (n + 1) for i in range(1, n + 1): prefixArr[i] = prefixArr[i - 1] + arr[i - 1] bestTotal...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CAL...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
T = int(input()) for t in range(T): n, k, z = map(int, input().split()) arr = [int(x) for x in input().split()] answer = arr[0] for take in range(z + 1): sum = 0 for i in range(k - 2 * take + 1): sum += arr[i] for i in range(min(k - 2 * take + 1, n - 1)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
q = int(input()) for i in range(q): n, k, z = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] sp = [(arr[i] + arr[i + 1]) for i in range(len(arr) - 1)] res = sum(arr[: k + 1]) for j in range(z, 0, -1): if k + 1 - 2 * j > 0 and k + 1 - 2 * j > 0: res = ma...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split(" "))) si = 0 ans = 0 si = a[0] s = [0] * n s[0] = a[0] for i in range(1, n): s[i] = s[i - 1] + a[i] for i in range(1, n): if i > k: break si +=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
import sys input = sys.stdin.readline def ceil(x): if x != int(x): x = int(x) + 1 return x def swaparr(arr, a, b): temp = arr[a] arr[a] = arr[b] arr[b] = temp def gcd(a, b): if b == 0: return a return gcd(b, a % b) def nCr(n, k): if k > n - k: k = n - k ...
IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
n = int(input()) for i in range(n): n, k, z = map(int, input().split()) l = list(map(int, input().split())) s = sum(l[: k + 1]) m = [(l[i] + l[i - 1]) for i in range(1, k + 1)] ans = s for i in range(1, z + 1): c = s if 1 + k - 2 * (i - 1) >= 1 and (i - 1) * 2 + 1 <= len(m): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def solve(n, k, z, ar): ans = 0 for t in range(z + 1): pos = k - 2 * t if pos < 0: continue maxi = 0 s = 0 for i in range(pos + 1): if i < n - 1: maxi = max(ar[i] + ar[i + 1], maxi) s += ar[i] ans = max(ans, s + ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
for _ in range(int(input())): n, k, z = map(int, input().split()) a = [*map(int, input().split())] s = [0] for i in a: s.append(s[-1] + i) ans = s[k + 1] k -= 1 for i in range(1, n): temp = s[i + 1] mzk = min(z, k // 2) temp += mzk * (a[i] + a[i - 1]) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VA...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for _ in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) dp = [[([0] * 2) for i in range(z + 1)] for i in range(k + 1)] dp[0][0][0] = a[0] for i in range(k): for times in range(z + 1): pos = i - 2 * times if pos >= 0:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) for i in range(t): n, k, z = map(int, input().split()) a = list(map(int, input().split())) j = 0 pre = [0] while j < n: pre.append(pre[-1] + a[j]) j += 1 j = 1 ans = a[0] while j < n: curr = k - j if curr == 0: ans = max(ans, p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBE...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
t = int(input()) while t > 0: n, k, z = [int(x) for x in input().split()] l_s = list(map(int, input().split())) p_sum = [] s = 0 d = z ans = 0 for i in l_s[: k + 1]: s += i p_sum.append(s) for i in range(1, k + 1): l = k - i score = p_sum[i] z = d ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR FOR ...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
def solution(): n, k, z = list(map(int, input().split())) a = list(map(int, input().split())) a1 = sorted([(a[i], i) for i in range(k + 1)], reverse=True) sums = [a[0]] for i in range(1, n): sums.append(sums[i - 1] + a[i]) answer = 0 for ai, pos in a1: rest_k = k - pos ...
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 VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR...
You are given an array $a_1, a_2, \dots, a_n$, consisting of $n$ positive integers. Initially you are standing at index $1$ and have a score equal to $a_1$. You can perform two kinds of moves: move right — go from your current index $x$ to $x+1$ and add $a_{x+1}$ to your score. This move can only be performed if $x...
from sys import stdin def r(): return stdin.readline().strip() def r_t(tp): return map(tp, r().strip().split()) def r_a(tp): return list(r_t(tp)) def solve(n, k, z, A): ans = float("-inf") for t in range(0, z + 1): ac, x = 0, -1 for i in range(k - 2 * t + 1): ac +...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP ...