description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
The only difference between easy and hard versions is constraints. If you write a solution in Python, then prefer to send it in PyPy to speed up execution time. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of $n$ students. Student...
n, m = [int(i) for i in input().split()] line = [int(x) for x in input().split()] count = {(i + 1): (0) for i in range(100)} sum = 0 for i in line: p = sum + i t = 0 if p > m: for j in range(100, 0, -1): if count[j] == 0: continue elif p - count[j] * j > m: ...
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 BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR NU...
The only difference between easy and hard versions is constraints. If you write a solution in Python, then prefer to send it in PyPy to speed up execution time. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of $n$ students. Student...
n, M = map(int, input().split()) t = list(map(int, input().split())) f = [(0) for _ in range(101)] a = [] for i in range(n): Mi = M - t[i] c = 0 for j in range(1, 101): k = min(Mi // j, f[j]) Mi -= k * j c += k a.append(i - c) f[t[i]] += 1 print(" ".join(map(str, 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 ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BI...
The only difference between easy and hard versions is constraints. If you write a solution in Python, then prefer to send it in PyPy to speed up execution time. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of $n$ students. Student...
n, m = list(map(int, input().split())) arr = list(map(int, input().split())) pre = [arr[0]] for i in range(1, n): pre.append(pre[-1] + arr[i]) ans = [] freq = [(0) for i in range(105)] for i in range(n): if pre[i] <= m: ans.append(0) else: x = pre[i] cnt = 0 d = x - m ...
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 LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL ...
The only difference between easy and hard versions is constraints. If you write a solution in Python, then prefer to send it in PyPy to speed up execution time. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of $n$ students. Student...
n, m = map(int, input().split()) t = list(map(int, input().split())) tIndex = {} tIndexSum = {} s = 0 for i in range(n): r = 0 if s + t[i] > m: keys = list(tIndex.keys()) keys.sort(reverse=True) s1 = s for k in keys: if s1 - tIndex[k] * k + t[i] > m: s...
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 DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
T = int(input()) for t in range(T): n = int(input()) cs = [int(x) for x in input().split()] bests = [cs[0], cs[1]] totals = [cs[0], cs[1]] ans = 12345677890123409875678 for i in range(2, n + 1): firsts = i - i // 2 - 1 seconds = i // 2 - 1 cost = ( bests[0] * ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) def ans(ar, n): mi = ar[0] ix = 0 pre = ar[0] bmi = ar[1] bix = 1 bpre = ar[1] su = n * (ar[0] + ar[1]) for i in range(2, n): if (i + 1) % 2: if mi > ar[i]: mi = ar[i]...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for s in [*open(0)][2::2]: a = s.split() i = len(a) j = 0 r = p = 1000000000000000.0 b = [0, 0] c = [p, p] for x in map(int, a): j ^= 1 i -= j b[j] += x c[j] = min(c[j], x) x = b[j] + c[j] * i r = min(r, p + x) p = x print(r)
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for tt in range(t): n = int(input()) c = list(map(int, input().split())) s = [c[0], c[1]] x = [c[0], c[1]] ans = sum(x) * n for i in range(2, n): I = i % 2 s[I] += c[i] x[I] = min(x[I], c[i]) ss = sum(s) + x[0] * (n - i // 2 - 1) + x[1] * (n - (i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for x in range(int(input())): n = int(input()) arr = list(map(int, input().strip().split())) a = [arr[0]] b = [arr[1]] amin = arr[0] bmin = arr[1] asum = arr[0] bsum = arr[1] alen = 1 blen = 1 help = bmin * (n - blen) + bsum + amin * (n - alen) + asum for i in range(2, n)...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) mc = a[0] * n + a[1] * n mec = a[0] moc = a[1] es = a[0] os = 0 ec = 1 oc = 0 for i in range(1, n): if i % 2 == 0: mec = min(mec, a[i]) es += a[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASS...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys def load_sys(): return sys.stdin.readlines() def load_local(): with open("input.txt", "r") as f: input = f.readlines() return input def f(n, costs): odd_sum = 0 even_sum = 0 odd_cnt = 0 even_cnt = 0 odd_mn = float("inf") even_mn = float("inf") ans = float...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF FUNC_CALL VAR STRING STRING VAR ASSIGN VAR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for testis in range(int(input())): n = int(input()) c = list(map(int, input().split())) x, y = c[0], c[1] res = [x * n + y * n] r = 0 for i in range(2, n): if i % 2 == 0: if c[i] < x: r += x x = c[i] else: r += c[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NU...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def find(): n = int(input()) mas = list(map(int, input().split())) min1 = mas[0] min2 = mas[1] ans1 = mas[0] * n ans2 = mas[1] * n res = ans1 + ans2 s1 = mas[0] s2 = mas[1] j1 = j2 = 1 for j in range(2, len(mas)): if j % 2 == 0: s1 += mas[j] mi...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) lh = [] lv = [] for i in range(0, n, 2): lh.append(l[i]) for i in range(1, n, 2): lv.append(l[i]) minans = 10000000000 minh = 100000000000 minv = 100000000000 sumh = 0 sumv = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): x = int(input()) zoo = list(map(int, input().split())) ans = zoo[0] * x + zoo[1] * x sum1 = zoo[0] sum2 = zoo[1] min1 = zoo[0] min2 = zoo[1] count1 = 1 count2 = 1 p2 = zoo[1] * x for i in range(2, x): if i % 2 == 0: sum1 += zo...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUM...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) flag = True a = [] b = [] for i in l: if flag: a.append(i) else: b.append(i) flag = not flag x = len(a) y = len(b) z = max(x, y) la = lb = n ca =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) l = list(map(int, input().split())) odds = [] evens = [] for i in range(n): if i % 2 == 0: evens.append(l[i]) else: odds.append(l[i]) for i in range(1, len(evens)): evens[i] += evens[i - 1] f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR F...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) c1 = [c[i] for i in range(0, n, 2)] c2 = [c[i] for i in range(1, n, 2)] pref1 = [0] pref2 = [0] for i in range(len(c1)): pref1.append(c1[i] + pref1[i]) ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for ad in range(int(input())): n = int(input()) l = list(map(int, input().split())) m1 = l[0] m2 = l[1] ans = m1 * n + m2 * n x = ans for i in range(2, n): if i % 2 == 0: if l[i] < m1: ans -= m1 * (n - i // 2) m1 = l[i] ans ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUM...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = iter(sys.stdin.read().splitlines()).__next__ def solve(): n = int(input()) c = list(map(int, input().split())) min_cost_right = c[0] min_cost_up = c[1] min_cost = min_cost_right * n + min_cost_up * n cost = min_cost for i in range(2, n): if i % 2: if...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for u in range(int(input())): n = int(input()) x = [int(w) for w in input().split()] ans = n * x[0] + n * x[1] s1 = x[0] s2 = x[1] m1 = x[0] m2 = x[1] l1 = 1 l2 = 1 for k in range(2, n): if k % 2 == 0: s1 += x[k] l1 += 1 m1 = min(m1, x[...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
num_test_case = int(input()) for t in range(num_test_case): num_segments = int(input()) segments = [int(x) for x in input().split(" ")] min_cost_x_segment = segments[0] min_cost_x = min_cost_x_segment * num_segments min_cost_y_segment = segments[1] min_cost_y = min_cost_y_segment * num_segments ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER V...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) b0 = 10**10 b1 = 10**10 sm = 0 res = 10**18 for i in range(n): if i % 2 == 0: if c[i] < b0: b0 = c[i] elif c[i] < b1: b1 = c[i] sm += c[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def calc(): n = int(input()) c = list(map(int, input().split(" "))) hor_sum = c[0] hor_min = c[0] ver_sum = c[1] ver_min = c[1] hors = 1 vers = 1 min_cost = n * c[0] + n * c[1] for i in range(2, n): if i % 2 == 0: hors += 1 hor_sum += c[i] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) min1 = a[0] min2 = a[1] temp1 = min1 * n temp2 = min2 * n ans = temp1 + temp2 sm1 = 0 sm2 = 0 counter1 = 0 counter2 = 0 for i in range(n): if i % 2 == 0: sm1 += a[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) c = [int(x) for x in input().split()] prices, mn_e, mn_o, s = 10**20, c[0], c[1], c[0] for i in range(2, n + 1): s += c[i - 1] if i % 2 == 0 and i != n: mn_e = min(mn_e, c[i]) elif i % 2 == 1 and i != n: mn_o ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUM...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
tc = int(input()) for t in range(tc): n = int(input()) path = [int(x) for x in input().split()] even = True curBest = n * path[0] + n * path[1] minEven = path[0] minOdd = path[1] curEvenSum = path[0] curOddSum = path[1] cntEven = 1 cntOdd = 1 for i in path[2:]: if eve...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys t = int(sys.stdin.readline()) for _ in range(t): n = int(sys.stdin.readline()) l = list(map(int, sys.stdin.readline().split())) right = l[0] up = l[1] su = l[1] + l[0] udone = 1 rdone = 1 low = l[1] * n + l[0] * n for i in range(2, n): su += l[i] if i % 2 ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) min1 = a[0] min2 = 1000000000.0 ans = 1e18 sum = a[0] for i in range(1, n): sum = sum + a[i] if i % 2 == 1: min2 = min(min2, a[i]) else: min1 = min(min1, a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) f1 = [0] * n f2 = [0] * n f1[0] = l[0] f2[1] = l[1] m1 = [0] * n m2 = [0] * n m1[0] = l[0] m2[1] = l[1] for i in range(2, n): if i % 2 == 0: f1[i] = f1[i - 2] + l[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSI...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def main(): t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) if n == 2: print(2 * (c[0] + c[1])) else: o_min = c[0] e_min = c[1] o_sum = c[0] e_sum = c[1] o_min_i = 0 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBE...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
from sys import stdin input = stdin.readline T = int(input()) for _ in range(T): n = int(input()) segs = list(map(int, input().split())) row = float("inf") col = segs[0] base_row = 0 base_col = segs[0] res_row = 0 res_col = segs[0] * n res = float("inf") for i in range(1, len(se...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) m = n costs = [int(i) for i in input().split()] horizontal, vertical, ch_old, cv_old = 0, 0, 0, 0 gesamt = sum(costs) * n var, var2 = True, False min_ch = max(costs) min_cv = min_ch for c in costs: if var: if c ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
INF = 10**20 def solve(): n = int(input()) (*c,) = map(int, input().split()) min_odd = INF min_ev = INF sum_odd = 0 sum_ev = 0 ans = INF cnt_o = n cnt_e = n for i, x in enumerate(c): if i % 2 == 0: min_odd = min(min_odd, x) sum_odd += x ...
ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) c = list(map(int, input().split())) rmin = rtot = c[0] umin = utot = c[1] hprice = rmin * n uprice = umin * n ans = hprice + uprice for i in range(2, n): if i & 1: utot += c[i] ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) best = float("inf") mn = [float("inf")] * 2 sm = [0] * 2 for i in range(n): mn[i % 2] = min(mn[i % 2], arr[i]) sm[i % 2] += arr[i] best = min(best, sum(sm[j] + mn[j] * (n - (i - j) // 2 -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n = int(input()) A = list(map(int, input().split())) mv1 = A[0] mv2 = A[1] v1, v2 = n, n ans = v1 * mv1 + v2 * mv2 ans1 = 0 for i in range(2, n): if i % 2 == 0: if A[i] < mv1: a...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for s in [*open(0)][2::2]: l = [*map(int, s.split())] q = l[::2] qn = len(q) w = l[1::2] wn = len(w) n = len(l) c = [] s = [0, 0] m = [1000000000000000.0, 1000000000000000.0] p = [n, n] for i in range(n): x = i & 1 m[x] = min(m[x], l[i]) s[x] += l[i] ...
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
from itertools import accumulate from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def solve(): n = int(input()) cc = [int(a) for a in input().split()] ...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def solve(C, n): MUC = [0] * n MDC = [0] * n minUCost = minDCost = 10**10 for i in range(n): if i % 2 == 0: minUCost = min(C[i], minUCost) else: minDCost = min(C[i], minDCost) MUC[i] = minUCost MDC[i] = minDCost minTotalCost = 10**15 uStepC...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
from sys import stdin input = stdin.readline t = int(input()) for _ in range(t): n = int(input()) c = [int(x) for x in input().split()] min_r = c[0] min_u = c[1] cc = [c[0] + c[1]] r = [min_r] u = [min_u] for i in range(2, n): if i % 2 == 0: min_r = min(min_r, c[i]) ...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) def slv(n, a): m0, m1 = a[0], a[1] s0, s1 = a[0], a[1] c0, c1 = 1, 1 ans = m0 * n + m1 * n for i in range(2, n): if i % 2 == 0: m0 = min(m0, a[i]) c0 += 1 s0 += a[i] else: m1 = min(m1, a[i]) c1 += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def solve(n, c): king_hoz, king_vert = c[0], c[1] stair_sum = 0 reach_sum = n * c[0] + n * c[1] m = stair_sum + reach_sum singles_sum = c[0] + c[1] hoz_singles = vert_singles = 1 for i in range(2, n): singles_sum += c[i] cost = singles_sum if i % 2 == 0: i...
FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR ASS...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) c1 = 10**9 c2 = 10**9 s1 = 0 s2 = 0 ans = 10**15 for i in range(n): if i % 2 == 0: s1 += c[i] if c1 > c[i]: c1 = c[i] if i % 2 == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for g in range(t): n = int(input()) s = list(map(int, input().split())) a = [s[0], s[1]] mn = [s[0], s[1]] cnt = [1, 1] ans = (s[0] + s[1]) * n for i in range(2, n): mn[i % 2] = min(mn[i % 2], s[i]) a[i % 2] += s[i] cnt[i % 2] += 1 ans = min( ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUM...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def main(): def win(n, weights): evenmin, oddmin = weights[0], weights[1] evenp, oddp = weights[0], weights[1] evenc, oddc = 1, 1 val = n * (weights[0] + weights[1]) for i in range(2, n): oddp = oddp + i % 2 * weights[i] evenp = evenp + (i + 1) % 2 * ...
FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) n1 = 0 n2 = 0 mx = float("inf") my = float("inf") cst = float("inf") sum = 0 for i in range(1, n + 1): sum += c[i - 1] if i % 2 == 0: n1 += 1 mx = min(mx, ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
T = int(input()) for t in range(1, T + 1): N = int(input()) C = list(map(int, input().split())) min_cost = 2**100 sum_even, sum_odd = 0, C[0] min_even, min_odd = 2**100, C[0] even, odd = 0, 1 for i, c in enumerate(C[1:]): if i % 2 == 0: sum_even += c min_even ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def MI(): return map(int, sys.stdin.readline().split()) def SI(): return sys.stdin.readline().strip() t = II() for s1 in range(t): n = II() l = LI() ans = l[0] * n + ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) costs = input().split() costs = [int(item) for item in costs] minPathCost = (costs[0] + costs[1]) * n horizSum = 0 vertSum = 0 minHoriz = 10**10 minVert = 10**10 numHoriz = 0 numVert = 0 for i in range(n): if i % 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n, clist1, clist2, p1, p = int(input()), [], [], 0, 0 clist = list(map(int, input().split(" "))) m1 = m2 = ans1 = float("inf") for i in range(n): if i & 1: clist1.append(clist[i]) m1 = min(m1, clist[i]) else: clist2.append...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASS...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) c = list(map(int, input().split())) d = [0] * n m = 10**10 s1 = [0] for i in range(0, n, 2): s1.append(s1[-1] + c[i]) m = min(m, c[i]) d[i] = s1[-1] + m * (n - len(s1) + 1) m = 10**10 s1 = [0] for i in range(1, n,...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBE...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for i in range(t): n = int(input()) c = list(map(int, input().split())) sum_right = c[0] sum_up = c[1] min_right = c[0] min_up = c[1] count_up = 1 count_right = 1 cost = sum_right + sum_up + min_up * (n - count_up) + min_right * (n - count_right) for k in range(2...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) m1 = a[0] m2 = a[1] s1 = a[0] s2 = 0 z1 = 1 z2 = 0 min_cost = m1 * n + m2 * n for i in range(1, n): if i % 2 == 1: if a[i] < m2: m2 = a[i] cost =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) count = arr[0] * n + arr[1] * n mi0 = arr[0] mi1 = arr[1] ma0 = arr[0] ma1 = arr[1] dp = [count] mi0_count = n mi1_count = n for i in range(2, n): if i % 2 == 0: if arr[i]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIS...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def local_ans(n, count, _min, _sum): return (n - count + 1) * _min + (_sum - _min) def solve(n, cc): min_ans = None _next = 2 count1 = 1 min1 = cc[0] sum1 = cc[0] count2 = 0 min2 = cc[1] sum2 = 0 for i in range(1, len(cc)): if _next == 2: count2 += 1 ...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def main(): for ii in range(int(input())): n = int(input()) a = list(map(int, input().split())) odd_sum = a[1] even_sum = a[0] xo, xe = a[1], a[0] c = xo * n + xe * n for i in range(2, n): if i % 2: odd_sum += a[i] x...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMB...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for tt in range(t): n = int(input()) c = list(map(int, input().split())) s = [c[0], c[1]] x = [c[0], c[1]] ans = sum(x) * n for i in range(2, n): I = i % 2 s[I] += c[i] x[I] = min(x[I], c[i]) ss = sum(s) + x[0] * (n - i // 2 - 1) + x[1] * (n - (i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def answer(): ans = 1e50 m1, m2 = 1e50, 1e50 v1, v2, c1, c2 = 0, 0, 0, 0 for i in range(n): if i & 1: m1 = min(m1, a[i]) v1 += a[i] c1 += 1 else: m2 = min(m2, a[i]) v2 += a[i] c2 += 1 ans = min(ans, v1 + v2 +...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline def main(): t = int(input()) for _ in range(t): N = int(input()) C = [int(x) for x in input().split()] ans = float("inf") mi_even = float("inf") mi_odd = float("inf") total_even = 0 total_odd = 0 cnt_even = ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUM...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def a(): t = int(input()) o = [] for i in range(t): n = int(input()) c = list(map(int, input().split())) x = [c[0]] y = [c[1]] mx = c[0] my = c[1] sx = c[0] sy = c[1] r = c[0] * n + c[1] * n for j in range(2, n): if ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSI...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def solve(): n = int(input()) a = list(map(int, input().split())) m0 = a[0] m1 = a[1] s0, s1 = a[0], a[1] m, s = [0] * n, [0] * n m[0], m[1] = m0, m1 s[0], s[1] = s0, s1 for i in range(2, n): if i % 2: if a[i] < m1: m1 = a[i] m[i] = m1 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMB...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) ans = 10**18 som = 0 cnt1 = 0 cnt2 = 0 x = 10**18 y = 10**18 for i in range(n): if i % 2 == 0: x = min(x, l[i]) cnt1 += 1 ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for i in range(t): n = int(input()) zoz = [int(j) for j in input().split()] ma = 10**9 + 1 mb = 10**9 + 1 cs = 0 fin = [] for j in range(n): if j % 2 == 0: if zoz[j] < ma: if ma != 10**9 + 1: cs += ma ma...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
T = int(input()) r = 1 while r <= T: n = int(input()) arr = list(map(int, input().split())) minh, minv = arr[0], arr[1] tot = (minh + minv) * n ans = tot for i in range(2, n): if i % 2 == 0: if arr[i] < minh: tot -= (n - i // 2) * (minh - arr[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def ints(): return list(map(int, input().split())) def case(): (n,) = ints() c = ints() cx = c[::2] cy = c[1::2] cy.append(cy[-1]) res = cx[0] * n + cy[0] * n mincx = cx[0] sumcx = cx[0] mincy = cy[0] sumcy = cy[0] for i in range(1, (n + 1) // 2): if cx[i] < min...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER AS...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for t in range(int(input())): n = int(input()) l = list(map(int, input().split())) oc = n ec = n min_o = float("inf") min_e = float("inf") res = 0 ans = float("inf") for i in range(n): if i % 2 == 0: res += l[i] ec -= 1 min_e = min(min_e, l...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def min_cost(n: int, costs: list) -> int: ans = float("inf") even, odd = 0, 0 even_cost, odd_cost = 0, 0 even_min, odd_min = float("inf"), float("inf") for cost in costs: if even > odd: odd += 1 odd_cost += cost odd_min = min(odd_min, cost) else: ...
FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline def print(x, end="\n"): sys.stdout.write(str(x) + end) for _ in range(int(input())): n = int(input()) c = list(map(int, input().strip().split())) total = c[0] + c[1] no_odd = 1 no_even = 1 min_odd = c[0] min_even = c[1] ans = total + (n - no...
IMPORT ASSIGN VAR VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) INF = 10**18 for _ in range(t): n = int(input()) c = list(map(int, input().split())) m = [INF, INF] s = [0, 0] cnt = [0, 0] ans = INF for i in range(n): m[i % 2] = min(c[i], m[i % 2]) s[i % 2] += c[i] cnt[i % 2] += 1 v = 0 for i in ran...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) a = arr[0] b = arr[1] ans = a * n + b * n s = 0 for i in range(2, n): if i % 2 == 0: if a < arr[i]: s += arr[i] else: s += a ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def main(n, l): minim = n * l[0] + n * l[1] min_odd = sum_odd = l[1] min_even = sum_even = l[0] even_count = odd_count = 1 for i in range(2, n): if i % 2 == 0: min_even = min(min_even, l[i]) sum_even += l[i] even_count += 1 else: min_od...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys t = int(input()) for _t in range(t): n = int(input()) c_inp = [int(e) for e in input().strip().split()] minv = float("inf") sum0, min0, len0 = c_inp[0], c_inp[0], 1 sum1, min1, len1 = c_inp[1], c_inp[1], 1 for k in range(1, n): if k != 1: if k % 2 == 0: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_C...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) a = [[], []] for i, x in enumerate(c): a[i % 2].append(x) ma = [a[0].copy(), a[1].copy()] ms = [a[0].copy(), a[1].copy()] ma[0][0] = a[0][0] ms[0][0] = a[0][0] for i in range(1, len(a[0])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FUNC_CALL VAR NUMBER FUNC_CALL VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline t = int(input()) for tests in range(t): n = int(input()) C = list(map(int, input().split())) A = [] B = [] for i in range(n): if i % 2 == 0: A.append(C[i]) else: B.append(C[i]) MINA = 1 << 60 SUMA = 0 ANSA = [...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
list1 = [] for i in range(int(input())): n = int(input()) s = list(map(lambda x: int(x), input().split())) price = n * s[0] + n * s[1] min_1, min_2 = s[0], s[1] k = n - 1 price1 = price for j in range(2, n): if j % 2 == 0: price1 = price1 + s[j] - min_1 if s[j...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) c = [int(x) for x in input().split()] pre = [0] * n pre[0] = c[0] for i in range(1, n): pre[i] = pre[i - 1] + c[i] lmin2 = [[c[0], c[1]]] l1 = c[0] l2 = c[1] res = n * (l1 + l2) for i in range(2, n): if i + 1 & 1: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 VAR VAR ASSIGN VAR LIST LIST VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
T = int(input()) for _ in range(T): N = int(input()) c = list(map(int, input().split())) up, right = c[0], 0 mup, mright = c[0], 2000000000.0 cup, cright = 1, 0 M = 9e18 for i in range(1, N): if i & 1: right += c[i] cright += 1 mright = min(mright,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) cx = c[1] * n cy = c[0] * n odd_sum = min_odd = c[1] even_sum = min_even = c[0] odds = evens = 1 min_cost = cx + cy for i in range(2, n): if i & 1: odds += 1 odd_s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys def solve(n, costs): pref = [costs[0]] for i in costs[1:]: pref.append(i + pref[-1]) i0 = 0 i1 = 0 min0 = costs[0] min1 = costs[1] m = n * (min0 + min1) for i in range(2, n): if i & 1: i1 += 1 min1 = min(min1, costs[i]) else: ...
IMPORT FUNC_DEF ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def solve(n, arr): mnm = [0] * n mnm[0] = arr[0] mnm[1] = arr[1] sm = [0] * n sm[0] = arr[0] sm[1] = arr[1] for i in range(2, n): mnm[i] = min(arr[i], mnm[i - 2]) sm[i] = arr[i] + sm[i - 2] m = float("inf") for i in range(n - 1): x = sm[i] + sm[i + 1] ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR B...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys from sys import stdin def solve(N, C): best_cost = N * C[0] + N * C[1] cur_cost = N * C[0] + N * C[1] min_1 = C[0] min_2 = C[1] use_min_1 = N + 0 use_min_2 = N + 0 for i in range(2, N): if i % 2 == 0: cost = C[i] if cost < min_1: c...
IMPORT FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def prob3(C, n): minCost = (C[0] + C[1]) * n oddMin = C[0] evenMin = C[1] oddSum, evenSum = C[0], C[1] oddCount, evenCount = 1, 1 for i in range(2, len(C)): if i % 2 == 0: oddCount += 1 oddSum += C[i] oddMin = min(oddMin, C[i]) minCost = mi...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) arr = [int(i) for i in input().split()] emin = float("inf") omin = float("inf") ans = float("inf") temp = 0 od = n ev = n for i in range(n): if i % 2 == 0: val = temp + od * arr[i] + ev * emin ans = min(an...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF B...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def solve(c): m = min(c) k = len(c) return m * (n - k) + sum(c) t = int(input()) ans = [] for i in range(t): n = int(input()) arr = [int(i) for i in input().split()] res = arr[0] * n + arr[1] * n curr = res rmin, umin = arr[0], arr[1] for i, v in enumerate(arr[2:], start=2): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
from sys import stderr, stdin input = stdin.readline def dbp(*args, **kwargs): print(*args, file=stderr, **kwargs) def get_int_list(): return [int(x) for x in input().strip().split()] def do_thing(): n = int(input()) clist = get_int_list() mincost = float("inf") mineven = clist[0] min...
ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) l = list(map(int, input().split())) h = [] v = [] for i in range(n): if i % 2 == 0: h.append(l[i]) else: v.append(l[i]) hl = len(h) hv = len(v) p = n * (h[0] + v[0]) hmin = h[0] vmin = v[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for s in [*open(0)][2::2]: (*a,) = map(int, s.split()) n = len(a) r = p = 1e18 b = [p, p] + a a = [0, 0] + a for i in range(2, n + 2): a[i] += a[i - 2] b[i] = min(b[i], b[i - 2]) x = a[i] + b[i] * (n - i // 2) r = min(r, p + x) p = x print(r)
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys from sys import stdin tt = int(stdin.readline()) ANS = [] for loop in range(tt): n = int(stdin.readline()) c = list(map(int, stdin.readline().split())) ans = float("inf") anum = 0 asum = 0 amin = float("inf") bnum = 0 bsum = 0 bmin = float("inf") for i in range(n): ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN V...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) c = list(map(int, input().split())) mas1, mas2 = [], [] minn1, minn2, ans = 10000000000, 10000000000, 1000000000000000 summ = 0 for i in range(n): summ += c[i] if i % 2 == 1: minn1 = min(minn1, c[i]) mas1.appe...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def cum_sum(in_list): for i in range(1, len(in_list)): in_list[i] += in_list[i - 1] return in_list def move(n, costs): cum_sum = costs[0] even_min, even_cnt = costs[0], 1 odd_min, odd_cnt = 10**9 + 1, 0 tl_cnt_odd = n // 2 tl_cnt_even = n - tl_cnt_odd best = None for i in r...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER FU...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
quist = int(input()) for count in range(quist): m = int(input()) c = list(map(int, input().split())) c1 = [] c2 = [] w = 0 for i in c: if w == 0: c1.append(i) w = 1 else: c2.append(i) w = 0 n1 = 0 s1 = 0 m1 = -1 d1 =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VA...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) costs = list(map(int, input().split())) cum_costs = [0] * n min_costs = [10000000000.0] * n min_total_cost = 1000000000000000.0 for i in range(n): if i < 2: cum_costs[i] = costs[i] min_costs[i] = costs[i] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
def path(arr): ne, no = len(arr), len(arr) me, mo = float("inf"), float("inf") s, ans = 0, float("inf") for i in range(len(arr)): if i % 2 == 0: ne -= 1 me = min(me, arr[i]) s += arr[i] else: no -= 1 mo = min(mo, arr[i]) ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) cs = [int(c) for c in input().split()] sum_odds = 0 min_odds = 1000000000 num_odds = 0 sum_evens = 0 min_evens = 1000000000 num_evens = 0 ans = 1000000000000000.0 for i in range(len(cs)): if i % 2 == 0: num_...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL V...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for _ in range(t): n = int(input()) l = list(list(map(int, input().split()))) dp = [0] * n dp[0] = float("inf") mn1 = l[0] mn2 = l[1] sm = l[0] + l[1] dp[1] = l[0] * n + l[1] * n for i in range(2, n): if i % 2 == 0: mn1 = min(mn1, l[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP ...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline def inp(): return int(input()) def st(): return input().rstrip("\n") def lis(): return list(map(int, input().split())) def ma(): return map(int, input().split()) t = inp() while t: t -= 1 n = inp() a = lis() res = n * a[0] + n * a[1] a...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) right = [i for i in arr[::2]] up = [i for i in arr[1::2]] r, u = 999999999999999999999999, 99999999999999999999999 s1, s2 = 0, 0 total = 999999999999999999999999 for i in range(len(right)): s1 +=...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) ans = 10**200 hi, vi, hm, vm = 0, 0, 10**10, 10**10 x, y = 0, 0 for i in range(n): if i % 2 == 0: if c[i] < hm: hm = c[i] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR N...
Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$. You can move only in two directions: to the right, i. e. horizontally and in the direction that increase your $x$ coordinate, or up, i. e. vertically and in the direction that increase your $y$ coordinate. In other ...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) cost = float("inf") u1, r1 = n, n a = 0 b = 0 i = 0 s1, s2 = float("inf"), float("inf") while i < n: if i % 2 == 0: s1 = min(s1, l[i]) cost = min(cost, a + b + s1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC...