description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) (*a,) = map(int, input().split()) dp = [[p * a[0], (p + q) * a[0], (p + q + r) * a[0]] for i in range(n)] for i in range(1, n): dp[i][0] = max(dp[i - 1][0], p * a[i]) for i in range(1, n): dp[i][1] = max(dp[i - 1][1], dp[i][0] + q * a[i]) for i in range(1, n): dp[i][2]...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_CALL ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) pmax = [None] * n smax = [None] * n pmax[0] = a[0] * p for i in range(1, n): pmax[i] = max(pmax[i - 1], a[i] * p) smax[n - 1] = r * a[n - 1] for i in range(n - 2, -1, -1): smax[i] = max(smax[i + 1], a[i] * r) answer = -999999999999999999...
ASSIGN VAR 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 NONE VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) mp = mq = mr = -1e20 for i in map(int, input().split()): mp = max(mp, p * i) mq = max(mq, mp + q * i) mr = max(mr, mq + r * i) print(mr)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) A = list(map(int, input().split())) B = [p, q, r] def solve(): dp = [float("-inf")] * n dp[0] = B[0] * A[0] for i in range(1, n): dp[i] = max(B[0] * A[i], dp[i - 1]) for j in range(1, 3): new_dp = [float("-inf")] * n new_dp[0] = A[0] * B[j...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CAL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
R = lambda: map(int, input().split()) n, p, q, r = R() arr = list(R()) ps = [(p * x) for x in arr] for i in range(1, n): ps[i] = max(ps[i], ps[i - 1]) pqs = [(ps[i] + arr[i] * q) for i in range(n)] for i in range(1, n): pqs[i] = max(pqs[i], pqs[i - 1]) print(max(pqs[i] + r * arr[i] for i in range(n)))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) list1 = list(map(int, input().split())) pref = [list1[0]] suf = [list1[-1]] ans = -3 * 10**18 - 1 if p > 0: for i in range(1, n): pref.append(max(list1[i], pref[-1])) else: for i in range(1, n): pref.append(min(list1[i], pref[-1])) if r > 0: for i in ra...
ASSIGN VAR 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 VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CAL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
f = lambda: map(int, input().split()) n, p, q, r = f() a = list(f()) x = [(t * p) for t in a] y = [(t * q) for t in a] z = [(t * r) for t in a] for i in range(n - 1, 0, -1): z[i - 1] = max(z[i - 1], z[i]) for i in range(1, n): x[i] = max(x[i - 1], x[i]) print(max(x[i] + y[i] + z[i] for i in range(n)))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_C...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) x, y, z = -float("inf"), -float("inf"), -float("inf") for i in range(n): z = max(z, p * a[i]) y = max(y, z + q * a[i]) x = max(x, y + r * a[i]) print(x)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) num1, num2, num3 = -1e20, -1e20, -1e20 for x in a: num1 = max(num1, p * x) num2 = max(num2, num1 + q * x) num3 = max(num3, num2 + r * x) print(num3)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
class CodeforcesTask855BSolution: def __init__(self): self.result = "" self.n_p_q_r = [] self.a = [] def read_input(self): self.n_p_q_r = [int(x) for x in input().split(" ")] self.a = [int(x) for x in input().split(" ")] def process_task(self): dp = [([0] *...
CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def maxSum(arr, p, q, r): premax = -214748364800000000000000000000000000000 postmax = -2147483648000000000000000000000000000000 maxx = -214748364800000000000000000000000000000000000 pre = [] post = [] for i in arr: premax = max(p * i, premax) pre.append(premax) for j in range...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) u = [0] * n u[0] = a[0] * p for i in range(1, n): u[i] = max(u[i - 1], a[i] * p) u[0] += a[0] * q for i in range(1, n): u[i] = max(u[i] + q * a[i], u[i - 1]) u[0] += a[0] * r for i in range(1, n): u[i] = max(u[i] + r * a[i], u[i - 1]...
ASSIGN VAR 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 BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
inf = 10**18 n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) mx = [-inf] * n mn = [inf] * n val2 = [0] * n mx[0] = a[0] mn[0] = a[0] val2[0] = p * a[0] + q * a[0] for i in range(1, n): mn[i] = min(mn[i - 1], a[i]) mx[i] = max(mx[i - 1], a[i]) val2[i] = q * a[i] + max(mn[i] * p, mx...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR 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 VAR ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER AS...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) alist = list(map(int, input().split())) first = [alist[0]] if p < 0: for i in range(1, n): first.append(min(alist[i], first[i - 1])) else: for i in range(1, n): first.append(max(alist[i], first[i - 1])) last = [alist[n - 1]] if r < 0: for i in ran...
ASSIGN VAR 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 IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) ai = list(map(int, input().split())) maxp = ai[-1] * p maxq = ai[-1] * q maxr = ai[-1] * r maxqr = maxq + maxr ans = maxqr + maxp for i in range(n - 2, -1, -1): maxr = max(maxr, ai[i] * r) maxqr = max(maxqr, ai[i] * q + maxr) ans = max(ans, maxqr + ai[i] * p) print(ans...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys initial_inp = [] inp = [] n = input().split() count = int(n[0], 10) p = int(n[1], 10) q = int(n[2], 10) r = int(n[3], 10) arrString = input().split() arr = count * [None] for i in range(0, count): arr[i] = int(arrString[i], 10) def maximum(a, b): if a < b: return b else: return...
IMPORT ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR LIST NONE FOR VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def readints(): return [int(item) for item in input().split()] class Solver: def main(self): n, p, q, r = readints() a = [0] + readints() dp = [[(0) for _ in range(3)] for _ in range(n + 1)] dp[1][0] = p * a[1] dp[1][1] = (p + q) * a[1] dp[1][2] = (p + q + r) *...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = [int(s) for s in input().split()] dp = [] INF = 1000000000.0 + 5 for i in range(n + 1): dp.append([-(3 * INF * INF), -(3 * INF * INF), -(3 * INF * INF)]) for i in range(n): dp[i + 1][0] = max(dp[i][0], a[i] * p) dp[i + 1][1] = max(dp[i][1], dp[i + 1][0] + q * a[i])...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) b = a[::-1] ma = [0] * n mb = [0] * n Ma = [0] * n Mb = [0] * n ma[0] = Ma[0] = a[0] mb[0] = Mb[0] = b[0] for i in range(1, n): ma[i] = min(ma[i - 1], a[i]) mb[i] = min(mb[i - 1], b[i]) Ma[i] = max(Ma[i - 1], a[i]) Mb[i] = max(Mb...
ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
nn, p, q, r = map(int, input().split()) ar = list(map(int, input().split())) max_l = [ar[0]] for i in range(1, nn): max_l.append(max(max_l[-1], ar[i])) min_l = [ar[0]] for i in range(1, nn): min_l.append(min(min_l[-1], ar[i])) max_r = [0] * nn max_r[-1] = ar[-1] for i in range(nn - 2, -1, -1): max_r[i] = ma...
ASSIGN VAR 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 FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
s = input() inf = 1e30 s = [int(x) for x in s.split()] n = s[0] p = s[1] q = s[2] r = s[3] a = input() a = [int(x) for x in a.split()] dp = [] for i in range(n + 1): dp.append(0) dp[0] = -inf i = 1 while i <= n: now = p * a[i - 1] dp[i] = max(dp[i - 1], now) i = i + 1 i = 1 while i <= n: now = q * a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) arr = list(map(int, input().split())) def select_and_multiply(x, arr): if x >= 0: return x * arr[-1] return x * arr[0] def solve(): minFromLeft = [None for i in range(n)] maxFromLeft = [None for i in range(n)] minFromRight = [None for i in range(n)]...
ASSIGN VAR 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 FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FU...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def list_input(): return list(map(int, input().split())) def map_input(): return map(int, input().split()) def map_string(): return input().split() n, p, q, r = map_input() a = [p, q, r] b = list_input() ans = 0 INF = -100000000000000000000000 dp = [INF] * (n + 5) dp2 = [INF] * (n + 5) dp3 = [INF] * (...
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 VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
tmp = list(map(int, input().split())) n, p, q, r = tmp[0], tmp[1], tmp[2], tmp[3] a = list(map(int, input().split())) d1 = [] d2 = [] d3 = [] d1.append(p * a[0]) for i in range(1, n): d1.append(max(p * a[i], d1[i - 1])) d2.append(p * a[0] + q * a[0]) for i in range(1, n): d2.append(max(d1[i] + q * a[i], d2[i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split(" ")) a = list(map(int, input().split(" "))) maxi = -1000000000000000000000 b = [a[0]] c = [a[-1]] if p > 0: for i in range(1, n): b.append(max(b[i - 1], a[i])) else: for i in range(1, n): b.append(min(b[i - 1], a[i])) if r > 0: for i in range(1, n): ...
ASSIGN VAR 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 ASSIGN VAR LIST VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys def main(): import sys input = sys.stdin.readline n, p, q, r = map(int, input().split()) arr = list(map(int, input().split())) dp = [([-(10**27)] * 3) for _ in range(n)] dp[0][0] = p * arr[0] dp[0][1] = dp[0][0] + q * arr[0] dp[0][2] = dp[0][1] + r * arr[0] ans = dp[0][...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR 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 BIN_OP NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_O...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def f(n, p, q, r, a): dp = [[(0) for i in range(n)] for j in range(3)] dp[0][0] = p * a[0] dp[1][0] = dp[0][0] + q * a[0] dp[2][0] = dp[1][0] + r * a[0] for i in range(1, n): dp[0][i] = max(dp[0][i - 1], p * a[i]) dp[1][i] = max(dp[1][i - 1], dp[0][i] + q * a[i]) dp[2][i] = m...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) di = [[(0) for j in range(3)] for i in range(n)] di[0][0] = p * a[0] di[0][1] = a[0] * (p + q) di[0][2] = a[0] * (p + q + r) for i in range(1, n): di[i][0] = max(di[i - 1][0], p * a[i]) for i in range(1, n): di[i][1] = max(di[i - 1][1], ...
ASSIGN VAR 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
read_int = lambda string: list(map(int, string.split())) def max_until_i(k, arr, v): x = [None] * len(arr) x[0] = k * arr[0] + v[0] for i in range(1, len(arr)): x[i] = max(x[i - 1], k * arr[i] + v[i]) return x def main(): n, p, q, r = read_int(input()) arr = read_int(input()) x =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN VAR FUNC_DE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
N, P, Q, R = map(int, input().split()) arr = list(map(int, input().split())) l = float("-inf") Pmax = [0] * N Pmax[0] = P * arr[0] for i in range(1, N): Pmax[i] = max(Pmax[i - 1], P * arr[i]) Smax = [0] * N Smax[N - 1] = R * arr[N - 1] for j in range(N - 2, -1, -1): Smax[j] = max(R * arr[j], Smax[j + 1]) for i ...
ASSIGN VAR 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 STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, x, y, z = map(int, input().split(" ")) y1 = list(map(int, input().split())) dp = [0] * n for i in range(n): if i == 0: dp[i] = x * y1[i] else: dp[i] = max(x * y1[i] + dp[i], dp[i - 1]) for i in range(n): if i == 0: dp[i] = y * y1[i] + dp[i] else: dp[i] = max(dp[i - 1],...
ASSIGN VAR 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 ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) List = [int(x) for x in input().split()] MaxPre = [] MaxSuf = [] MinPre = [] MinSuf = [] Max = List[0] Min = List[0] for i in range(n): Max = max(Max, List[i]) Min = min(Min, List[i]) MaxPre.append(Max) MinPre.append(Min) Max = List[-1] Min = List[-1] for i in rang...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
a = list(map(int, input().split())) arr = list(map(int, input().split())) c = a[1:] pmax = [float("-inf") for i in range(a[0])] smax = [float("-inf") for i in range(a[0])] pmax[0] = c[0] * arr[0] v = float("-inf") for i in range(a[0]): pmax[i] = max(pmax[i - 1], c[0] * arr[i]) smax[a[0] - 1] = c[2] * arr[a[0] - 1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NU...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys input1 = input().split() input1 = list(map(int, input1)) n = input1[0] p = input1[1] q = input1[2] r = input1[3] arr = input().split() arr = list(map(int, arr)) def max_check(num1, num2): if num1 > num2: return num1 else: return num2 pre_max = [] pre_max.append(p * arr[0]) for i ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR LIST EXP...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys def get_list(): return list(map(int, sys.stdin.readline().strip().split())) def get_int(): return map(int, sys.stdin.readline().strip().split()) n, p, q, r = get_int() arr = get_list() p_max = [0] * n r_max = [0] * n ans = -1e20 p_max[0] = p * arr[0] r_max[n - 1] = r * arr[n - 1] for i in range...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMB...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys input = sys.stdin.buffer.readline def solution(): n, p, q, r = map(int, input().split()) l = list(map(int, input().split())) np = -2e19 nq = -2e19 nr = -2e19 for i in range(n): np = max(np, p * l[i]) nq = max(nq, np + q * l[i]) nr = max(nr, nq + r * l[i]) ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = [int(i) for i in input().split()] min_suf = [0] * n max_suf = [0] * n min_suf[-1] = [n - 1, a[n - 1]] max_suf[-1] = min_suf[-1] pqr = [0] * n qr = [0] * n rr = [0] * n rr[-1] = a[-1] * r for i in range(n - 2, -1, -1): if a[i] < min_suf[i + 1][1]: min_suf[i] = [i, a...
ASSIGN VAR 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 LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSI...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r2 = list(map(int, input().split())) a = list(map(int, input().split())) small = 10**9 + 1 large = -(10**9) - 1 infa = 10**9 + 1 infb = -(10**9) - 1 l = [] r = [] for i in range(0, n): small = min(small, a[i]) large = max(large, a[i]) l.append((small, large)) small = 10**9 + 1 large = -(10**9) - 1 ...
ASSIGN VAR 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 BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMB...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(i) for i in input().split(" ")] a = [int(i) for i in input().split(" ")] m_inf = float("-inf") dp = [] for i in range(n + 1): dp.append([m_inf, m_inf, m_inf]) for i in range(1, n + 1): dp[i][0] = max(dp[i - 1][0], a[i - 1] * p) dp[i][1] = max(dp[i - 1][1], dp[i][0] + a[i - 1] * q) dp[i...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
max_integer, map1 = max, map n, p, q, r = map1(int, input().strip().split()) list1 = list(map1(int, input().strip().split())) prefix_max, suffix_max, result = [0] * n, [0] * n, float("-inf") prefix_max[0] = p * list1[0] for i in range(1, n): prefix_max[i] = max_integer(prefix_max[i - 1], p * list1[i]) suffix_max[n ...
ASSIGN VAR VAR VAR VAR ASSIGN VAR 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 VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) rl = [a[-1] * r] pl = [a[0] * p] for i in range(2, n + 1): rl.append(max(rl[-1], a[-i] * r)) pl.append(max(pl[-1], a[i - 1] * p)) rl.reverse() ans = pl[0] + a[0] * q + rl[0] for i in range(1, n): ans = max(ans, pl[i] + a[i] * q + rl[...
ASSIGN VAR 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 BIN_OP VAR NUMBER VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR VAR EX...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) pqr = [p, q, r] mat = [[(0) for j in range(n)] for i in range(3)] for i in range(3): for j in range(n): if i == 0: if j == 0: mat[i][j] = pqr[i] * a[j] else: mat[i][j] = max(mat...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, a, b, c = map(int, input().split(" ")) l = list(map(int, input().split(" "))) dp = [([0] * n) for i in range(3)] dp[0][0] = a * l[0] dp[1][0] = dp[0][0] + b * l[0] dp[2][0] = dp[1][0] + c * l[0] for i in range(1, n): dp[0][i] = max(dp[0][i - 1], a * l[i]) dp[1][i] = max(dp[1][i - 1], dp[0][i] + b * l[i]) ...
ASSIGN VAR 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 BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUM...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) mxLeft = [a[0]] mnLeft = [a[0]] for i in range(1, n): mxLeft.append(max(mxLeft[-1], a[i])) mnLeft.append(min(mnLeft[-1], a[i])) mxRight = [a[n - 1]] mnRight = [a[n - 1]] for i in range(n - 2, -1, -1): mxRight.append(max(mxRight[-1], ...
ASSIGN VAR 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 VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) li = [] li = list(map(int, input().split())) for i in range(len(li)): if i == 0: x = li[i] * p y = li[i] * q + x z = li[i] * r + y else: x = max(li[i] * p, x) y = max(x + li[i] * q, y) z = max(y + li[i] * r, z) print(z)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
a = [int(x) for x in input().split()] b = [int(y) for y in input().split()] n = a[0] p, q, r = a[1], a[2], a[3] left = [] right = [] for i in range(n): left.append(b[i] * p) right.append(b[i] * r) prefixMax = [0] * n temp = -10000000000000000000 i = 0 while i < n: temp = max(temp, left[i]) prefixMax[i] ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def maxe(a, b): if a > b: return a elif a < b: return b else: return a def pmmax(a, p): x = 0 a[x] = a[x] * p max = a[0] y = x + 1 cap = len(a) - 1 while y != cap + 1: max = maxe(max, p * a[y]) a[y] = max y = y + 1 return a def ...
FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
a = input().split() n = int(a[0]) p, q, r = int(a[1]), int(a[2]), int(a[3]) ar = [p, q, r] array = input().split() fin = [] for i in array: fin.append(int(i)) dp = [[(0) for x in range(len(array))] for y in range(3)] i = 0 while i < len(array): j = 0 while j < 3: if i == 0: if j == 0: ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
inp = input().split() n = int(inp[0]) p = int(inp[1]) q = int(inp[2]) r = int(inp[3]) del inp del n a = input().split() mas_1 = list() mas_2 = list() mas_3 = list() max = int(a[0]) * p for i in a: if int(i) * p > max: max = int(i) * p mas_1.append(max) max = mas_1[0] + int(a[0]) * q for i in range(len(a...
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 VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) total = p + q + r if n == 1: print(total * a[0]) exit() if p > 0 and q > 0 and r > 0: print(total * max(a)) exit() if p < 0 and q < 0 and r < 0: print(total * min(a)) exit() p_vals = [None] * n p_vals[0] = p * a[0] for i ...
ASSIGN VAR 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 BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = list(map(int, input().strip().split())) arr = list(map(int, input().strip().split())) def find_pref_sum(array): maxm = -(2**63) pref_sum = [0] * n for i in range(0, n): pref_sum[i] = max(maxm, array[i] * p) maxm = max(maxm, array[i] * p) return pref_sum def f...
IMPORT ASSIGN VAR 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 FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(i) for i in input().split(" ")] inp_arr = [int(i) for i in input().split(" ")] prefix_max = [] suffix_max = [] maxi = -(2**63) for i in inp_arr: if i * p > maxi: maxi = i * p prefix_max.append(maxi) maxi = -(2**63) for i in range(n - 1, -1, -1): if inp_arr[i] * r > maxi: ma...
ASSIGN VAR 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 LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER F...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split(" "))) a = list(map(int, input().split(" "))) max1 = {} min1 = {} max2 = {} min2 = {} maxval1 = a[0] minval1 = a[0] maxval2 = a[n - 1] minval2 = a[n - 1] for i in range(n): j = n - 1 - i maxval1 = max(maxval1, a[i]) max1[i] = maxval1 minval1 = min(minval1, a[i]) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
maxi = ks = -554564764545467545566666634534554 l = list(map(int, input().split())) l1 = list(map(int, input().split())) r_list, p_list = [0] * len(l1), [0] * len(l1) r_list[-1] = l[3] * l1[-1] p_list[0] = l1[0] * l[1] for i in range(len(l1) - 2, -1, -1): r_list[i] = max(r_list[i + 1], l1[i] * l[3]) for i in range(1...
ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, a, b, c = map(int, input().split()) array = list(map(int, input().split())) val_max = (10**20 + 1) * -1 array_b = [] for x in range(n): if a * array[x] > val_max: val_max = a * array[x] array_b.append(b * array[x] + val_max) resp = (10**20 + 1) * -1 val_max = (10**18 + 1) * -1 for y in range(n): ...
ASSIGN VAR 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
f = lambda: map(int, input().split()) n, p, q, r = f() a = b = c = -(10**19) d = list(f()) for i in range(n): a = max(a, d[i] * p) b = max(b, a + d[i] * q) c = max(c, b + d[i] * r) print(c)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = map(int, input().split()) lst = list(map(int, input().split())) suffix_max = [(0) for _ in range(n)] suffix_max[n - 1] = r * lst[n - 1] for i in range(n - 2, -1, -1): suffix_max[i] = max(suffix_max[i + 1], lst[i] * r) left = lst[0] * p res = -999999999999999999999999999999 for i in range(n)...
IMPORT ASSIGN VAR 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 BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) arr = [int(i) for i in input().split()] parr = [arr[0] * p] for i in range(1, len(arr)): val = max(arr[i] * p, parr[i - 1]) parr.append(val) qarr = [arr[0] * q + p * arr[0]] for i in range(1, len(arr)): val = max(qarr[i - 1], arr[i] * q + parr[i]) qarr.append(val) ...
ASSIGN VAR 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 BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST BIN_OP B...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) A = list(map(int, input().split())) P = [(p * a) for a in A] Q = [(q * a) for a in A] R = [(r * a) for a in A] ans = -(10**20) for i in range(1, n): P[i] = max(P[i], P[i - 1]) PQ = [(0) for i in range(n)] for i in range(n): PQ[i] = P[i] + Q[i] if i: PQ[i] = max...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_C...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) nums = list(map(int, input().split())) dp = [[(0) for _ in range(n + 1)] for _ in range(4)] dp[0][0] = 0 coef = [p, q, r] for i in range(1, 4): for j in range(1, n + 1): if j == 1: dp[i][j] = dp[i - 1][j] + coef[i - 1] * nums[j - 1] else: ...
ASSIGN VAR 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 VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def get_ans(n, p, q, r, a): maxpre = [-100000000] * n minpre = [100000000] * n maxsuf = [-100000000] * n minsuf = [100000000] * n curmax = a[0] curmin = a[0] for i in range(n): if a[i] > curmax: curmax = a[i] maxpre[i] = curmax if a[i] < curmin: ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) minil = [0] * n minir = [0] * n maxil = [0] * n maxir = [0] * n minil[0] = maxil[0] = a[0] minir[n - 1] = maxir[n - 1] = a[n - 1] for i in range(1, n): minil[i] = min(minil[i - 1], a[i]) maxil[i] = max(maxil[i - 1], a[i...
IMPORT ASSIGN VAR 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 VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split(" "))) dpr = [(-(10**18)) for i in range(n)] dpr[-1] = r * a[-1] for k in reversed(range(n - 1)): dpr[k] = max(dpr[k + 1], r * a[k]) dpqr = [(-(10**18)) for i in range(n)] dpqr[-1] = (q + r) * a[-1] for k in reversed(range(n - 1)): dpqr[k] =...
ASSIGN VAR 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 BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(i) for i in input().split()] a = [int(i) for i in input().split()] crmx, crmn = [a[n - 1]] * n, [a[n - 1]] * n for i in range(n - 2, -1, -1): crmx[i] = max(crmx[i + 1], a[i]) crmn[i] = min(crmn[i + 1], a[i]) ans = 0 - 10**21 mn, mx = a[0], a[0] for i in range(n): cans = q * a[i] mx = m...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR BIN_OP LIST VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = input().split(" ") arr = input().split(" ") n = int(n) p = int(p) q = int(q) r = int(r) arr = [int(x) for x in arr] prefix_max = [] maximum = float("-inf") for i in range(len(arr)): prefix_max.append(max(maximum, p * arr[i])) maximum = prefix_max[-1] maxi = float("-inf") suffix_max = [(1**x) for x ...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR F...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) pre, suf = [p * a[0]], [r * a[n - 1]] * n for i in range(1, n): pre.append(max(pre[i - 1], p * a[i])) suf[n - i - 1] = max(suf[n - i], r * a[n - i - 1]) ans = -float("inf") for i in range(n): ans = max(ans, pre[i] + suf[i] + a[i] * q...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP VAR VAR NUMBER BIN_OP LIST BIN_OP VAR VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) INF = float("inf") R = [-INF] * n R[-1] = a[-1] * r for i in range(n - 2, -1, -1): R[i] = max(R[i + 1], a[i] * r) P = [-INF] * n P[0] = a[0] * p for i in range(1, n): P[i] = max(P[i - 1], a[i] * p) num = -INF for i in range(n): num =...
ASSIGN VAR 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 STRING ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def maxValue(arr, n, p, q, r): preMap = [0] * n preMap[0] = p * arr[0] suffMap = [0] * n suffMap[n - 1] = r * arr[n - 1] for i in range(1, n): if preMap[i - 1] >= p * arr[i]: preMap[i] = preMap[i - 1] else: preMap[i] = p * arr[i] for i in range(n - 2, -1, ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def Dumbledore2(n, p, q, r, arr): dp = [None] * 100000 dp[0] = p * arr[0] for i in range(1, n): dp[i] = max(dp[i - 1], arr[i] * p) dp1 = [None] * 100000 dp1[0] = dp[0] + q * arr[0] for i in range(1, n): dp1[i] = max(dp1[i - 1], arr[i] * q + dp[i]) dp2 = [None] * 100000 dp...
FUNC_DEF ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def modified_pre_max(arr, p): n = len(arr) arr1 = ["None"] * n arr1[0] = arr[0] * p for i in range(1, n): arr1[i] = max(arr1[i - 1], arr[i] * p) return arr1 def modified_suf_max(arr, r): n = len(arr) arr1 = ["None"] * n arr1[n - 1] = arr[n - 1] * r for i in range(n - 2, -1,...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def preMax(arr, coeff): tempArr = [arr[0] * coeff] for n in range(1, len(arr)): tempArr.insert(n, max(arr[n] * coeff, tempArr[n - 1])) return tempArr def suffMax(arr, coeff): tempArr = [arr[-1] * coeff] for n in range(len(arr) - 1, 0, -1): tempArr.insert(0, max(arr[n - 1] * coeff, ...
FUNC_DEF ASSIGN VAR LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUM...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys input = sys.stdin.readline n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) ml = [a[0]] Ml = [a[0]] for i in range(1, n): ml.append(min(ml[-1], a[i])) Ml.append(max(Ml[-1], a[i])) mr = [a[-1]] Mr = [a[-1]] for i in range(n - 2, -1, -1): mr.append(min(mr[-1], a[i])) ...
IMPORT ASSIGN VAR VAR ASSIGN VAR 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 VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CAL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = [int(x) for x in input().split()] pmax = [] * n smax = [] * n arr = list(map(int, input().split()))[:n] pmax.append(p * arr[0]) for i in range(1, n): pmax.append(max(pmax[i - 1], p * arr[i])) smax.append(r * arr[n - 1]) for i in range(n - 2, -1, -1): smax.insert(0, max(smax[0], r * arr[...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR ASSIGN VAR BIN_OP LIST VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = map(int, input().split()) arr = list(map(int, input().split())) suffix_max = [0] * n suffix_max[n - 1] = r * arr[n - 1] for i in range(n - 2, -1, -1): suffix_max[i] = max(suffix_max[i + 1], r * arr[i]) max_left = -1 * sys.maxsize * 10**15 ans = -1 * sys.maxsize * 10**15 for j in range(0, n)...
IMPORT ASSIGN VAR 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 VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = tuple(int(i) for i in input().split(" ")) data = [int(i) for i in input().split(" ")] prefix = [] suffix = [] prefix.append(data[0] * p) suffix.append(data[n - 1] * r) len_d = len(data) maxnum = prefix[0] for i in range(1, len_d): if maxnum < data[i] * p: maxnum = data[i] * p prefix.append(...
ASSIGN VAR VAR VAR VAR FUNC_CALL 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 LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR V...
You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right. Each cell of the matrix can be either free or locked. Let's call a path in the matrix a staircase if it: * starts and ends in the free cell; * visits only free cells; * ha...
from sys import stdin, stdout input = stdin.readline print = stdout.write n, m, q = list(map(int, input().split())) matrix = [[[0, 0] for i in range(m)] for j in range(n)] free = [[(True) for i in range(m)] for j in range(n)] ans = 0 for i in range(n): for j in range(m): if i > 0: matrix[i][j][...
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NU...
You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right. Each cell of the matrix can be either free or locked. Let's call a path in the matrix a staircase if it: * starts and ends in the free cell; * visits only free cells; * ha...
def main(): H, W, Q = map(int, input().split()) A = [[] for _ in range(H + W)] for i in range(H): for j in range(W): A[(i + j + 1) // 2 * 2].append(0) A[(i + j) // 2 * 2 + 1].append(0) RawAns = H * W Diff = [0] * (H + W) for i in range(H + W): K = len(A[i]...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMB...
You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right. Each cell of the matrix can be either free or locked. Let's call a path in the matrix a staircase if it: * starts and ends in the free cell; * visits only free cells; * ha...
class Array2d: def __init__(self, n, m, arr): self.n = n self.m = m self.arr = arr @classmethod def full(cls, n, m, fill_value): return cls(n, m, [fill_value] * (n * m)) @classmethod def from_list(cls, lst): n, m = len(lst), len(lst[0]) arr = [lst[0...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR BIN_OP LIST VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR NU...
You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right. Each cell of the matrix can be either free or locked. Let's call a path in the matrix a staircase if it: * starts and ends in the free cell; * visits only free cells; * ha...
import sys from sys import stdin def calc(l): assert l >= 0 return l * (l - 1) // 2 n, m, q = map(int, stdin.readline().split()) xy = [] color = [([0] * m) for i in range(n)] freenum = n * m ans = 0 maxi = [float("-inf")] * 2002 mini = [float("inf")] * 2002 for i in range(n): for j in range(m): ...
IMPORT FUNC_DEF VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_...
You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right. Each cell of the matrix can be either free or locked. Let's call a path in the matrix a staircase if it: * starts and ends in the free cell; * visits only free cells; * ha...
import sys input = sys.stdin.readline output = sys.stdout.write def solve(R, C, Q, queries): blocked = [([0] * C) for _ in range(R)] res = R * C for c in range(C): for ln in range(1, R + C + 1): nr = ln // 2 nc = c + (ln + 1) // 2 if nr >= R or nc >= C: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VA...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def betterString(self, s, t): def countSubSets(s): c, l, d = 1, [1], {} for i in range(len(s)): c *= 2 if s[i] in d: c -= l[d[s[i]] - 1] d[s[i]] = i + 1 l.append(c) retur...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR NUMBER LIST NUMBER DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR VAR VAR VAR VAR
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
def func(S): last = [-1] * 256 dp = [0] * (len(S) + 1) dp[0] = 1 for i in range(1, len(S) + 1): dp[i] = dp[i - 1] * 2 if last[ord(S[i - 1])] != -1: dp[i] -= dp[last[ord(S[i - 1])]] last[ord(S[i - 1])] = i - 1 return dp[len(S)] % int(1000000000.0 + 7) class Solut...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR FUNC_CALL...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def betterString(self, str1, str2): def funcall(string): count = 1 dicti = dict() for char in string: if char not in dicti: dicti[char] = count count *= 2 else: t...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR RETURN VAR
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def getLen(self, st): dp = [1] lo = dict() for i in range(1, len(st) + 1): dp.append(2 * dp[i - 1]) ch = st[i - 1] if ch in lo: j = lo[ch] dp[i] = dp[i] - dp[j - 1] lo[ch] = i return dp[-...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR RET...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def betterString(self, s1, s2): l = [0] * len(s1) l[0] = 2 h, h1 = {}, {} for i in range(len(s1)): h[i] = h1.get(s1[i], -1) h1[s1[i]] = i for i in range(1, len(s1)): if h[i] == -1: l[i] = l[i - 1] * 2 ...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_O...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def countSub(self, str): last = [-1] * 127 n = len(str) dp = [0] * (n + 1) dp[0] = 1 for i in range(1, n + 1): dp[i] = 2 * dp[i - 1] if last[ord(str[i - 1])] != -1: dp[i] -= dp[last[ord(str[i - 1])]] last[or...
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR VA...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def betterString(self, str1, str2): def count_subsequences(s): n = len(s) dp = [0] * (n + 1) dp[0] = 1 last = {} for i in range(1, n + 1): dp[i] = 2 * dp[i - 1] if s[i - 1] in last: ...
CLASS_DEF FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NU...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def subSequence(self, strn): answer = set() N = 1 << len(strn) for i in range(N): temp = "" for j in range(len(strn)): if i >> j & 1 == 1: temp += strn[j] answer.add(temp) return len(answer) ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSI...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def countSubsequences(self, s): freq = {} n = len(s) distinctCount = [0] * (n + 1) distinctCount[0] = 1 for i in range(1, n + 1): if s[i - 1] not in freq: distinctCount[i] = 2 * distinctCount[i - 1] else: ...
CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBE...
Given a pair of strings, Geek wants to find the better string. The better string is the string having more number of distinct subsequences. If both the strings have equal count of distinct subsequence then return str1. Example 1: Input: str1 = "gfg", str2 = "ggg" Output: "gfg" Explanation: "gfg" have 7 distinct subsequ...
class Solution: def rec(self, s): n = len(s) dp = [1] m = {} for i in range(n): if s[i] in m: dp.append(dp[i] * 2 - dp[m[s[i]] - 1]) else: dp.append(dp[i] * 2) m[s[i]] = i + 1 return dp[n] def betterStr...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR F...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
t = int(input()) for c in range(t): s = input() up_max = down_max = right_max = left_max = 0 (first_up) = last_up = first_down = last_down = first_left = last_left = ( first_right ) = last_right = 0 current_x = current_y = 0 horizontal_count = vertical_count = 0 for i in range(len(s)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSI...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
import sys input = sys.stdin.readline Q = int(input()) Query = [list(input().rstrip()) for _ in range(Q)] for S in Query: L = len(S) T = [(0, 0)] for s in S: x, y = T[-1] if s == "W": T.append((x, y + 1)) elif s == "S": T.append((x, y - 1)) elif s == ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR STRING EXPR FUNC_...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
for i in range(int(input())): s = input() lm, rm, um, dm = 0, 0, 0, 0 xp, yp = 0, 0 for ch in s: if ch == "W": yp += 1 elif ch == "A": xp -= 1 elif ch == "S": yp -= 1 else: xp += 1 lm = min(lm, xp) rm = max(r...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR A...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
INF = 100000000000.0 move = {"W": (0, 1), "A": (-1, 0), "S": (0, -1), "D": (1, 0)} def getExtremes(positions): minX, minY, maxX, maxY = ( [positions[0][0]], [positions[0][1]], [positions[0][0]], [positions[0][1]], ) for p in positions[1:]: minX.append(min(minX[-1], ...
ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR LIST VAR NUMBER NUMBER LIST VAR NUMBER NUMBER LIST VAR NUMBER NUMBER LIST VAR NUMBER NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
q = int(input()) for _ in range(q): d = [x for x in list(input())] x, y = 0, 0 minX, maxX, minY, maxY = 0, 0, 0, 0 allowW, allowS, allowA, allowD = True, True, True, True for v in d: if v == "W": y += 1 if y > maxY: maxY = y allowS = Tr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUM...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
def main(): h, v = hv = [0], [0] f = {"W": (v, -1), "S": (v, 1), "A": (h, -1), "D": (h, 1)}.get for _ in range(int(input())): del h[1:], v[1:] for l, d in map(f, input()): l.append(l[-1] + d) x = y = 1 for l in hv: lh, a, n = (min(l), max(l)), 200001, ...
FUNC_DEF ASSIGN VAR VAR VAR LIST NUMBER LIST NUMBER ASSIGN VAR DICT STRING STRING STRING STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER F...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
T = int(input()) for _ in range(T): cmd = input() mostL, mostR, mostB, mostT = 0, 0, 0, 0 mostLs, mostRs, mostBs, mostTs = [0], [0], [0], [0] x, y = 0, 0 i = 0 for c in cmd: i += 1 if c == "W": y += 1 if y > mostT: mostT = y ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR LIST NUMBER LIST NUMBER LIST NUMBER LIST NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR STRING VAR NUMBER IF VAR VAR AS...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
import sys input = sys.stdin.readline Q = int(input()) for testcases in range(Q): S = input().strip() X = Y = 0 MAXX = MINX = MAXY = MINY = 0 for s in S: if s == "D": X += 1 MAXX = max(MAXX, X) elif s == "A": X -= 1 MINX = min(MINX, X) ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING VAR ...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
t = int(input()) for _ in range(0, t): a = list(input()) nowx = 0 nowy = 0 maxx = 0 minx = 0 maxy = 0 miny = 0 tmaxx = 0 tminx = 0 tmaxy = 0 tminy = 0 highw = 0 highs = 0 widthd = 0 widtha = 0 for i in range(0, len(a)): if a[i] == "W": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
You have a string $s$ — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: 'W' — move one cell up; 'S' — move one cell down; 'A' — move one cell left; 'D' — move one cell right. Let $Grid(s)$ be the grid of minimum possible area such th...
for _ in range(int(input())): s = input() ar = ["AD", "WS"] nr = [[], []] for e in s: if e in ar[0]: nr[0].append(e) else: nr[1].append(e) b, c = [float("inf")] * 2, [float("inf")] * 2 for i in range(2): sm = [0] for el in nr[i]: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR LIST LIST LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER BIN_OP LIST FUNC_CALL VAR STRING NUMBER FOR ...