description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = list(map(int, input().split()))
ans = 0
p = -1
for i in range(n):
cur = l[i]
pre = l[i]
for j in range(i + 1, n):
cur += min(pre, l[j])
pre = min(pre, l[j])
pre = l[i]
for j in range(i - 1, -1, -1):
cur += min(pre, l[j])
pre = min(pre, l[j])
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASS... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
n = int(input())
m = list(map(int, input().split()))
INF = 10**9 + 1
ans = m[:]
def solve(l, r):
global ans
if l == r:
return m[l]
rslt = 0
minimum = min(enumerate(m[l : r + 1]), key=lambda x: x[1])
mi = l + minimum[0]
mv = minimum[1]
al = (mi - l + 1) * mv + (solve(mi ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def left_nearest_neighbour(array):
n = len(array)
neighbours = [-1] * n
for i in range(1, n):
j = i - 1
while j != -1 and array[j] >= array[i]:
j = neighbours[j]
neighbours[i] = j
return neighbours
def right_nearest_neighbour(array):
n = len(array)
neighbour... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def findHeights(n, m):
l = [0] * (n + 2)
r = [0] * (n + 2)
h = [0] * (n + 2)
for i in range(1, n + 1):
j = i - 1
while j > 0:
if m[j - 1] < m[i - 1]:
break
j -= 1
if j > 0:
l[i] = l[j] + (i - j) * m[i - 1]
else:
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER AS... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
maxfloors = 0
ind = 0
ans = list()
for i in range(n):
chosen = [(0) for i in range(n)]
count = m[i]
chosen[i] = m[i]
for j in range(i - 1, -1, -1):
chosen[j] = min(chosen[j + 1], m[j])
count += chosen[j]
for j in range(i + 1, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBE... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
floors = list(map(int, input().split()))
ans = []
total = 0
for i in range(n):
b = n * [0]
b[i] = floors[i]
s = 0
for j in range(i - 1, -1, -1):
b[j] = min(floors[j], b[j + 1])
for j in range(i + 1, n):
b[j] = min(floors[j], b[j - 1])
for ele in b:
s += e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def skyscraper(arr):
ans = []
mx = 0
for i in range(0, len(arr)):
base = arr.copy()
for l in range(i - 1, -1, -1):
base[l] = min(base[l], base[l + 1])
for r in range(i + 1, len(arr)):
base[r] = min(base[r], base[r - 1])
sm = sum(base)
if sm > m... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
M = list(map(int, input().split()))
s = 0
ans = [0] * n
for i in range(n):
temp = 0
cur = M[i]
m = [0] * n
for j in reversed(range(i)):
if M[j] >= cur:
temp += cur
m[j] = cur
else:
temp += M[j]
cur = M[j]
m[j] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR AS... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | from sys import *
def solve(a, n):
x = []
mi = 0
for i in range(n):
index = i
b = [a[index]] * n
s = a[index]
for i in range(index + 1, n):
b[i] = min(a[i], b[i - 1])
s += b[i]
for i in range(index - 1, -1, -1):
b[i] = min(a[i], b... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [int(x) for x in input().split()]
assert len(m) == n
def score(peak):
build = [None] * n
build[peak] = m[peak]
score = m[peak]
limit = m[peak]
for i in range(peak - 1, -1, -1):
limit = min(limit, m[i])
build[i] = limit
score += limit
limit = m[peak]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
m = list(map(int, input().split()))
heap = [[0, -1, 0]]
left = [0] * n
for i in range(n):
while heap[-1][0] > m[i]:
heap.pop()
_, j, s = heap[-1]
heap.append([m[i], i, s + m[i] * (i - j)])
left[i] = hea... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | from sys import exit
def iis():
return map(int, input().split())
def ii():
return int(input())
def liis():
return list(map(int, input().split()))
n = ii()
a = liis()
ans = 0
for i in range(n):
new_a = a[:]
start = i
end = i
while start > 0:
start -= 1
new_a[start] = m... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split(" ")))
def summ(k):
global n
global a
b = [0] * n
b[k] = a[k]
i = k - 1
while i >= 0:
b[i] = min(a[i], b[i + 1])
i -= 1
i = k + 1
while i <= n - 1:
b[i] = min(a[i], b[i - 1])
i += 1
return sum(b)
ans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUM... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
ch = input()
L4 = [int(i) for i in ch.split()]
ind_max = 0
L2 = [0] * n
L3 = [""] * n
for ind_max in range(n):
L = L4.copy()
for i in range(ind_max + 1, n):
L[i] = min(L[i - 1], L[i])
i = ind_max - 1
while True:
if i < 0:
break
L[i] = min(L[i], L[i + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split()))
Map = {}
ans = 0
for ind in range(n):
b = [i for i in a]
m = a[ind]
i = ind - 1
j = ind + 1
Min = m
s = m
while i >= 0:
Min = min(Min, b[i])
b[i] = Min
i -= 1
s += Min
Min = m
while j < n:
Mi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arr = list(map(int, input().split()))
ans = 0
p = 0
for i in range(n):
curr = arr[i]
prev = arr[i]
for j in range(i - 1, -1, -1):
prev = min(prev, arr[j])
curr += prev
prev = arr[i]
for k in range(i + 1, n):
prev = min(prev, arr[k])
curr += prev
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def left(i, a, m):
s = 0
if i < 0:
return s
for i in range(i, -1, -1):
if a[i] >= m:
s += m
else:
m = a[i]
s += m
a[i] = m
return s
def right(i, a, n, m):
s = 0
if i >= n:
return s
for i in range(i, n):
if ... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def get(i):
global n, m
cur = [0] * n
cur[i] = m[i]
for j in range(i - 1, -1, -1):
cur[j] = min(m[j], cur[j + 1])
for j in range(i + 1, n):
cur[j] = min(m[j], cur[j - 1])
return cur
n = int(input())
m = list(map(int, input().split()))
ans = -1
res = []
for i in range(n):
a ... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FU... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | inf = float("inf")
n = int(input())
a = [-inf] + [int(i) for i in input().split()] + [-inf]
for x in (0, 1):
stack = [0]
ns = [-1] * (n + 2)
for i in range(n, -1, -1):
while a[i] < a[stack[-1]]:
ns[stack.pop()] = i
stack += [i]
res = [0] * (n + 2)
for i in range(1, len(a)... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR FOR VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBE... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split()))
st = []
f = [(-1) for i in range(n)]
e = [n for i in range(n)]
for i in range(n):
while len(st) != 0 and a[st[-1]] >= a[i]:
st.pop()
if st != []:
f[i] = st[-1]
st.append(i)
st = []
for i in range(n - 1, -1, -1):
while len(st) != 0 and ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR IF VAR LIST ASSIGN VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
sta1 = []
dp1 = [0] * (N + 1)
for i, a in enumerate(A):
count = 0
mustscore = dp1[i]
while sta1 and sta1[-1][0] > a:
s, num = sta1.pop()
count += num
mustscore += (s - a) * num
dp1[i + 1] ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR NUMBER NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
n = 0
S = []
h = []
def maxS():
st = []
left = [0] * n
right = [n - 1] * n
for i in range(n):
while len(st) > 0 and st[-1][0] >= h[i]:
right[st[-1][1]] = i - 1
del st[-1]
st.append((h[i], i))
st.clear()
for i in range(n - 1, -1, -1):
... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER VAR VAR ASSIGN VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | _DEBUG = 0
_W = 7
def debug(obj):
if _DEBUG:
print(f"{obj}.{' ' * (_W - len(obj))}", end="")
obj = eval(obj)
if type(obj) is list:
print("\t".join(list(map(str, obj))))
else:
print(obj)
def inp():
global n, arr
if _DEBUG:
n = 3
arr ... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR EXPR FUNC_CALL VAR VAR STRING BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR ASSIGN VAR NUMBER ASSIG... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split()))
ans_sum = 0
ans = a[:]
for max_i in range(n):
ca = a[:]
min_v = a[max_i]
for i in range(max_i - 1, -1, -1):
if ca[i] > min_v:
ca[i] = min_v
else:
min_v = ca[i]
min_v = a[max_i]
for i in range(max_i + 1, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
def is_sorted(test_list, begin, end):
flag = False
if all(test_list[i] <= test_list[i + 1] for i in range(begin, end - 1)):
flag = True
if not flag and all(
test_list[i] >= test_list[i + 1] for i in range(begin, end - 1)
):
f... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | N = int(input())
X = list(map(int, input().split()))
mxr = 0, 0
for i in range(N):
I = i
r = X[i]
b = r
while i > 0:
i -= 1
b = min(X[i], b)
r += b
i = I
b = X[i]
while i < N - 1:
i += 1
b = min(X[i], b)
r += b
if r > mxr[0]:
mxr = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR WHILE V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 0
ind = -1
for i in range(n):
tmp = a[i]
l = i
r = i
max_height = a[i]
for j in range(0, l)[::-1]:
if a[j] >= max_height:
tmp += max_height
else:
tmp += a[j]
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = list(map(int, input().split()))
ind = 0
mx = max(l)
ans = -1
A1 = [0] * n
for ind in range(n):
l1 = []
l2 = []
for i in range(ind - 1, -1, -1):
l1.append(l[i])
for i in range(ind, n):
l2.append(l[i])
curr = 1000000009
a1 = []
ans1 = 0
for i in l1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXP... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = [0] + list(map(int, input().split())) + [0]
def mnsprava(a):
inf = int(2000000000.0) + 1
ans1 = [0] * (n + 2)
st = [0]
for i in range(1, n + 2):
while a[st[-1]] > a[i]:
ans1[st.pop()] = n - i + 1
st.append(i)
ans1.reverse()
return ans1[1:-1]
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHI... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | from sys import stdin
def inp():
return next(ss.rstrip() for ss in stdin)
def itg():
return int(inp())
def mpint():
return map(int, inp().split())
n = itg()
arr = list(mpint())
left = [0] * n
right = [0] * n
left[0] = arr[0]
stack = [0]
for i in range(1, n):
while stack and arr[i] <= arr[stack[-... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIG... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def set_inc(lis6):
lis6 = lis6[::-1]
if len(lis6) != 0:
count = lis6[0]
for j1 in range(len(lis6)):
if lis6[j1] > count:
lis6[j1] = count
count = lis6[j1]
return lis6[::-1]
def set_dec(lis5):
if len(lis5) != 0:
count2 = lis5[0]
fo... | FUNC_DEF ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
x = [int(i) for i in input().split()]
s = [(0) for _ in x]
def getVol(i, j) -> int:
if i > j:
return 0
if i == j:
s[i] = x[i]
return x[i]
min_v = min(x[i : j + 1])
min_ind = x[i : j + 1].index(min_v) + i
if min_ind == i:
s[i] = min_v
return ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = eval(input())
h = list(map(int, input().split()))
L = [(0) for i in range(len(h))]
R = [(0) for i in range(len(h))]
ans = [(0) for i in range(len(h))]
stack = []
for i in range(len(h)):
while len(stack) and h[stack[-1][0]] >= h[i]:
stack.pop()
if len(stack) == 0:
stack.append((i, (i + 1) * h... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | N = int(input())
m = list(map(int, input().split()))
L = [0] * N
L[0] = -1
stack = [0]
for i in range(1, N):
while stack and m[stack[-1]] >= m[i]:
stack.pop()
if stack:
L[i] = stack[-1]
else:
L[i] = -1
stack.append(i)
dp = [0] * N
for i in range(0, N):
if L[i] == -1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR IF VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def r():
stack = [0]
ns = [-1] * (n + 2)
for i in range(n, -1, -1):
while a[i] < a[stack[-1]]:
ns[stack.pop()] = i
stack += [i]
s = [0] * (n + 2)
for i in range(1, len(a)):
s[i] = s[ns[i]] + a[i] * (i - ns[i]) if ns[i] else i * a[i]
return s
inf = float("inf... | FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
l = []
r = [0] * n
stack = []
m_l = [0] * n
m_r = [0] * n
for i in range(n):
h = m[i]
while stack and h < stack[-1][0]:
stack.pop()
if stack:
ph, pi = stack[-1]
l.append(h * (i - pi) + l[pi])
else:
l.append(h * (i + 1))... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR NUMBER NUMBER EXP... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = list(map(int, input().split()))
l3 = []
l4 = []
for i in range(n):
ll = [0] * n
s = 0
a = l[i]
for j in range(i, -1, -1):
if l[j] >= a:
ll[j] = a
else:
ll[j] = l[j]
a = l[j]
s += a
a = l[i]
for j in range(i, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
sys.setrecursionlimit(10**9)
n = int(input())
m = list(map(int, input().split()))
def solution(start, end, fill):
if start > end:
return 0, []
if start == end:
return m[start] - fill, [m[start] - fill]
min_value = 1000000000
min_index = []
for i in range(start, end + 1)... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER LIST IF VAR VAR RETURN BIN_OP VAR VAR VAR LIST BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def f():
def calcLeftSum(n, M):
def binSearch1(low, high, memo, e):
if memo[low][0] >= e:
return low
else:
while high - low > 1:
mid = (low + high) // 2
if memo[mid][0] >= e:
high = mid
... | FUNC_DEF FUNC_DEF FUNC_DEF IF VAR VAR NUMBER VAR RETURN VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER B... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
n = int(input())
l = [int(i) for i in input().split()]
g = [0] * len(l)
summa = 0
for index in range(n):
l1 = [0] * len(l)
l1[index] = l[index]
i, j = index - 1, index + 1
while i >= 0:
l1[i] = min(l1[i + 1], l[i])
i -= 1
while j < n:
l1... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def main():
N = int(input())
m = list(map(int, input().split()))
LV = (N - 1).bit_length()
N0 = 2**LV
data = [0] * (2 * N0)
lazy = [None] * (2 * N0)
def gindex(l, r):
L = l + N0 >> 1
R = r + N0 >> 1
lc = 0 if l & 1 else (L & -L).bit_length()
rc = 0 if r & 1 e... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR N... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | t = int(input())
c = input().split(" ")
estado = "nada"
for i in range(0, t):
c[i] = int(c[i])
max = []
tot = 0
spikes = [0]
for i in range(0, t - 1):
if c[i] > c[i + 1]:
estado = "bajada"
elif c[i] < c[i + 1] and estado == "bajada":
spikes.append(i)
spikes.append(i)
estado =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR STR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
def re1(a, i1, n):
ref = a[i1]
for i in range(i1, 0, -1):
if a[i] >= a[i - 1]:
ref = a[i - 1]
continue
else:
a[i - 1] = ref
ref = a[i1]
for i in range(i1, n - 1):
if a[i] >= a[i + 1]:
ref = a... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER AS... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arra = list(map(int, input().split()))
i = 1
maxi = 0
arra = [0] + arra + [0]
while i <= n:
array = arra[:]
add = array[i]
j = 0
k = 1
while True:
if i - j == 0:
break
if array[i - j - 1] > array[i - j]:
array[i - j - 1] = array[i - j]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR VAR NUMBER IF ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split()))
st = []
L = [(0) for _ in range(n)]
R = [(0) for _ in range(n)]
for i in range(n):
while st and a[st[-1]] >= a[i]:
st.pop()
if st:
L[i] = L[st[-1]] + (i - st[-1]) * a[i]
else:
L[i] = (i + 1) * a[i]
st.append(i)
st = []
for i in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR IF VAR ASSIGN VAR VAR BIN_OP VAR VAR NUM... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
ar = list(map(int, input().split()))
ans = []
x = 0
for i in range(n):
an = [0] * n
s = ar[i]
l = i
r = i + 1
an[i] = ar[i]
while l > 0:
l -= 1
s += min(ar[l], an[l + 1])
an[l] = min(ar[l], an[l + 1])
while r < n:
s += min(ar[r], an[r - 1])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE VAR NUMBER VAR NUMBER VAR FU... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def r(x, d):
stack = [-1]
s = [0] * x
for i in range(x - 1, -1, -1):
while d[i] < d[stack[-1]] and stack[-1] != -1:
stack.pop()
s[i] = (
(x - i) * d[i] if stack[-1] == -1 else s[stack[-1]] + d[i] * (stack[-1] - i)
)
stack += [i]
return s
def tota... | FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR LIST VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arr = list(map(int, input().split()))
ans = []
s = 0
for j in range(n):
mx = arr[j]
ans1 = []
ans2 = []
idx = j
mi = mx
for i in range(idx - 1, -1, -1):
mi = min(mi, arr[i])
ans1 = [mi] + ans1
mi = mx
for i in range(idx + 1, n):
mi = min(mi, arr[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CAL... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
curm = 0
ele = min(m)
res = []
for akidx in range(n):
arr = [m[akidx]]
prev = m[akidx]
for i in range(akidx + 1, n):
prev = min(prev, m[i])
arr.append(prev)
arr = arr[::-1]
prev = arr[-1]
for i in range(akidx - 1, -1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR E... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [int(x) for x in input().split()]
a = [0] * n
a[0] = m[0]
for i in range(1, n):
value = m[i]
for j in range(i - 1, -1, -1):
if m[j] > m[i]:
value += m[i]
else:
value += a[j]
break
a[i] = value
m.reverse()
b = [0] * n
b[0] = m[0]
for i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [int(i) for i in input().split()]
ready_solution = []
max_floors = 0
for top in range(n):
copy_of_the_m = m.copy()
candidate = 0
for left in range(top - 1, -1, -1):
if copy_of_the_m[left] <= copy_of_the_m[left + 1]:
candidate += copy_of_the_m[left]
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUM... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
n = int(sys.stdin.readline())
m = [int(x) for x in sys.stdin.readline().split()]
ans = 0
arr = [0] * n
for i in range(n):
floors = m[i]
tmp = [0] * n
tmp[i] = m[i]
prev = m[i]
for j in range(i - 1, -1, -1):
num = min(prev, m[j])
floors += num
tmp[j] = num
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMB... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | (N,) = map(int, input().split())
X = list(map(int, input().split()))
stack = [[0, 0, 0]]
ls = []
for i in range(N):
tmp = [1, X[i], X[i]]
while stack:
if stack[-1][1] < tmp[1]:
tmp[2] = tmp[0] * tmp[1] + stack[-1][2]
stack.append(tmp)
break
else:
x... | ASSIGN 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 LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR VAR VAR VAR WHILE VAR IF VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | from sys import stdin
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
stack = [(0, 0)]
left = [0]
for i, x in enumerate(a):
i += 1
while stack[-1][0] > x:
stack.pop()
left.append(left[stack[-1][1]] + x * (i - stack[-1][1]))
stack.append((x, i))
stack = [(0, 0)]
right = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER WHILE VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR VAR NUMBER NU... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [-1] + [int(i) for i in input().split()] + [-1]
l = [0] * (n + 2)
r = [0] * (n + 2)
ans_right = [0] * (n + 2)
st = [0]
for i in range(1, n + 2):
while m[st[-1]] > m[i]:
ans_right[st.pop()] = i
st.append(i)
ans_left = [0] * (n + 2)
st_2 = [0]
for i in range(n + 1, 0, -1):
while m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
ans = []
acval = 0
for peak in range(n):
lans = [0] * n
val = 0
prevmax = m[peak]
l = peak
while l >= 0:
if m[l] >= prevmax:
val += prevmax
lans[l] = prevmax
else:
prevmax = m[l]
val ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = input().split()
for i in range(n):
l[i] = int(l[i])
a = []
for j in range(n):
if j != n - 1:
min = l[j]
all = l[j]
for i in range(j + 1, n):
if l[i] >= min:
all += min
else:
min = l[i]
all += min
if j != 0:
min ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR ASSIGN VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
def main():
N = int(input())
M = [int(x) for x in input().split()]
ans = float("inf")
ansi = 0
for i in range(N):
tmp = 0
mi = M[i]
for j in range(i + 1, N):
if M[j] > mi:
tmp += M[j] - mi
else:
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [int(num) for num in input().split()]
rightlessque = []
indrightless = [n] * n
lastind = -1
for i in range(n):
while rightlessque and m[i] < m[rightlessque[lastind]]:
lastind -= 1
indrightless[rightlessque.pop()] = i
rightlessque.append(i)
lastind += 1
leftlessque = []
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BI... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
x = list(map(int, input().split()))
ans, y = [0, 0], [0] * 1001
for i in range(n):
lim, count = x[i], x[i]
for i2 in range(i - 1, -1, -1):
count += min(x[i2], lim)
lim = min(lim, x[i2])
lim = x[i]
for i2 in range(i + 1, n):
count += min(x[i2], lim)
lim = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FU... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
res = list(map(int, input().split()))
di = {}
for j in range(0, n):
r = l = res[j]
m = res.copy()
for i in range(j + 1, n):
if m[i] > r:
m[i] = r
r = m[i]
for i in range(j - 1, -1, -1):
if m[i] > l:
m[i] = l
l = m[i]
di[sum(m)]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | input = __import__("sys").stdin.readline
print = __import__("sys").stdout.write
n = int(input())
height = list(map(int, input().split()))
l = [(0) for _ in range(n)]
r = [(0) for _ in range(n)]
l_min = 10**9 + 1
for i in range(n):
if height[i] <= l_min:
l_min = height[i]
l[i] = (i + 1) * l_min
e... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
def solve(N, M):
def makeMountain(i):
m = M[i]
curr = m
left = []
for j in range(i - 1, -1, -1):
curr = min(M[j], curr)
left.append(curr)
curr = m
right = []
for j in range(i + 1, len(M)):
curr = min(M[j], curr... | IMPORT FUNC_DEF FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arr = list(map(int, input().strip().split()))
inc = [(0) for i in range(n)]
dec = [(0) for i in range(n)]
for i in range(n):
last = arr[i]
sc = arr[i]
for j in range(i - 1, -1, -1):
if arr[j] < last:
sc += arr[j]
last = arr[j]
else:
sc += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
hmax = list(map(int, input().split()))
ans = 0
seq: list
for i in range(n):
sumi = 0
cur = hmax[i]
seqi = [0] * n
for j in range(i, n):
cur = min(cur, hmax[j])
seqi[j] = cur
sumi += cur
cur = hmax[i]
for j in range(i - 1, -1, -1):
cur = min(cur, h... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
ans, idx = 0, -1
for i in range(n):
a = [0] * n
a[i] = m[i]
for j in range(i - 1, -1, -1):
a[j] = min(m[j], a[j + 1])
for j in range(i + 1, n):
a[j] = min(m[j], a[j - 1])
tot = sum(a)
if tot > ans:
ans = tot
idx... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
def getAr(o, n):
stk = list()
ans = [0] * n
ans[0] = o[0]
stk.append(0)
for i in range(1, n):
while len(stk) != 0 and o[stk[-1]] >= o[i]:
stk.pop()
multi = None
if len(stk) > 0:
ans[i] = ans[stk[-1]]
multi = i - stk[-1]
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NONE IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = [int(x) for x in input().split()]
final = 0
ar = [0] * n
for i in range(n):
mn = 10**10
ans = 0
for j in range(i, -1, -1):
mn = min(mn, l[j])
ans += mn
mn = 10**10
for j in range(i + 1, n):
mn = min(mn, l[j])
ans += mn
if ans > final:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
num = []
s = input().split()
nu = 0
for k in s:
j = int(k)
num.append(j)
for i1 in range(n):
su = 0
numd = [(0) for i in range(n)]
if i1 == 0:
numd[i1] = num[i1]
su += numd[i1]
for jj in range(i1 + 1, n):
if num[jj] > numd[jj - 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
ms = [int(a) for a in input().split()]
ms.insert(0, 0)
ms.insert(len(ms), 0)
an = []
an2 = [0]
for i in range(n + 2):
an.append(10**10)
for i in range(n + 2):
try:
if ms[i] <= ms[i + 1] and ms[i + 1] > ms[i + 2]:
peak = i + 1
an[peak] = ms[peak]
for j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arr = list(map(int, input().split()))
b = []
for i in range(n):
b.append([arr[i], i])
def sortFirst(val):
return val[0]
b.sort(key=sortFirst, reverse=True)
min_jog = None
index = -1
for i in range(n):
jog = 0
a = arr[:]
if b[i][1] != 0 and b[i][1] != n - 1:
for j in rang... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER A... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
best_score = 0
best_ans = []
for i in range(n):
ans = [(0) for _ in range(n)]
ans[i] = m[i]
score = m[i]
left, right = m[i], m[i]
for j in range(i + 1, n):
right = min(m[j], right)
ans[j] = right
score += right
for j in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def prevSmaller(array):
stack = []
result = []
n = len(array)
for num in range(n):
while stack and stack[-1][0] >= array[num]:
stack.pop()
if stack:
result.append(stack[-1][1])
else:
result.append(0)
stack.append([array[num], num + 1])
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def rmin(a, n):
ans = [-1] * (n + 2)
st = [0]
res = []
for i in range(1, n + 1):
while a[st[-1]] > a[i]:
ans[st.pop()] = n + 1 - i
st.append(i)
for i in range(1, n + 1):
res.append(ans[i])
return res
n = int(input())
inf = int(2000000000.0) + 1
m = [int(x) f... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | N = int(input())
m = list(map(int, input().split()))
sumAns = 0
ans = []
for i in range(N):
l = [(0) for i in range(N)]
Sum = 0
l[i] = m[i]
Sum += l[i]
for j in reversed(range(0, i)):
l[j] = min(m[j], l[j + 1])
Sum += l[j]
for j in range(i + 1, N):
l[j] = min(m[j], l[j - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def count_floor(arr, peak):
ans = [arr[peak]]
for i in range(peak + 1, len(arr)):
if arr[i] <= ans[-1]:
ans.append(arr[i])
else:
ans.append(ans[-1])
i = peak - 1
brr = [arr[peak]]
while i >= 0:
if arr[i] <= brr[-1]:
brr.append(arr[i])
... | FUNC_DEF ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR VAR WHILE VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | inf = int(2000000000.0) + 1
n = int(input())
a = [-inf] + [int(x) for x in input().split()] + [-inf]
def minLR(n, a):
ans = [0] * (n + 2)
st = [0]
for i in range(1, n + 2):
while a[st[-1]] > a[i]:
ans[st.pop()] = i
st.append(i)
return ans[1:-1]
a.reverse()
ansL = minLR(n,... | ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR NUMBE... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def skyscappers(n, m):
count_max = 0
ans = []
optimal_peak = 0
for i in range(n):
plan = [None] * n
peak = m[i]
count = peak
plan[i] = m[i]
for j in range(i - 1, -1, -1):
prev = plan[j + 1]
floor = m[j]
if floor <= prev:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = [0] + list(map(int, input().split())) + [0]
stk = [0] * (n + 2)
le, ri = [0] * (n + 2), [0] * (n + 2)
pos = [0] * (n + 2)
ans = [0] * (n + 2)
top = 0
for i in range(1, n + 1):
while top and stk[top] > m[i]:
top -= 1
le[i] = le[pos[top]] + (i - pos[top]) * m[i]
top += 1
stk[t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | inf = float("inf")
n = int(input())
a = [-inf] + list(map(int, input().split())) + [-inf]
rans = [0] * (n + 2)
rst = [0]
lans = [0] * (n + 2)
lst = [n + 1]
for i in range(1, n + 2):
while a[rst[-1]] > a[i]:
rans[rst.pop()] = i
rst.append(i)
while a[lst[-1]] > a[n + 1 - i]:
lans[lst.pop()] = ... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST BIN_OP VAR NUMB... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
arr = list(map(int, input().split()))
ans = 0
res = None
for i in range(n):
temp = list(arr)
mini = arr[i]
for j in range(i - 1, -1, -1):
temp[j] = min(temp[j], mini)
mini = min(mini, temp[j])
mini = arr[i]
for j in range(i + 1, n):
temp[j] = min(temp[j], min... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def do_solve(ns):
n = len(ns)
st = []
tot = []
res = []
for i, num in enumerate(ns):
while st and ns[st[-1]] >= num:
st.pop()
tot.pop()
pre = 0 if not tot else tot[-1]
length = i + 1 if not st else i - st[-1]
tot.append(pre + ns[i] * length)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
M = list(map(int, input().split()))
area1 = [M[0]] + [0] * (n - 1)
index = [0]
for i in range(1, n):
if M[i] >= M[i - 1]:
area1[i] = area1[i - 1] + M[i]
else:
while len(index) > 0 and M[i] < M[index[-1]]:
index.pop()
if len(index) == 0:
area1[i] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR WH... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def right_calculate_dp(dp_arr, m, curr_pos, curr_h_pos):
if curr_pos == len(m):
return 0
if dp_arr[curr_pos][curr_h_pos][1] != 0:
return dp_arr[curr_pos][curr_h_pos][1]
else:
if m[curr_h_pos] > m[curr_pos]:
curr_h_pos = curr_pos
dp_arr[curr_pos][curr_h_pos][1] = m... | FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER NUMBER RETURN VAR VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER NUMBER RETURN... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
m = list(map(int, input().split()))
btm = list()
peak = list()
if n > 1:
if m[0] >= m[1]:
peak.append(0)
if m[-1] >= m[-2]:
peak.append(n - 1)
for i in range(n - 2):
if m[i] >= m[i + 1] and m[i + 2] >= m[i + 1]:
btm.append(i + 1)
elif m[i] <= m[i + 1] and m[i + 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
a = list(map(int, input().split()))
l = [0] * n
r = [n - 1] * n
stack = [0]
for i in range(1, n):
while len(stack) > 0 and a[stack[-1]] >= a[i]:
stack.pop()
if len(stack) > 0:
l[i] = stack[-1]
else:
l[i] = i
stack.append(i)
stack = [n - 1]
for i in range(n - 2, -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR IF FUN... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
from _collections import deque
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(input())
a = list(map(int, input().split()))
front = [0] * n
back = [0] * n
slide = deque([])
for i in range(n):
while slide and a[i] < a[slide[-1]]:
slide.pop()
if not slide:
front[i] = (i + ... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR NUMBER EXPR FUN... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
(*a,) = map(int, input().split())
ms = 0
for idx in range(n):
ans, s = [], 0
c = a[idx]
for i in range(idx, -1, -1):
c = min(c, a[i])
ans.append(c)
s += c
ans = ans[::-1]
c = a[idx]
for i in range(idx + 1, n):
c = min(c, a[i])
ans.append(c... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN V... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def opt(a):
if len(a) <= 1:
return a
mi = a.index(min(a))
sl = opt(a[:mi])
sr = opt(a[mi + 1 :])
if sum(sl) + (len(a) - mi) * a[mi] > sum(sr) + (mi + 1) * a[mi]:
return sl + [a[mi]] * (len(a) - mi)
else:
return [a[mi]] * (mi + 1) + sr
n = int(input())
m = list(map(int, ... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR RETURN BIN_OP VAR B... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
inf = int(2000000000.0) + 1
N = [-inf] + list(map(int, input().split())) + [-inf]
st1 = [0]
minRight = [0] * (n + 2)
st2 = [0]
minLeft = [0] * (n + 2)
for i in range(1, n + 2):
while N[i] < N[st1[-1]]:
minRight[st1.pop()] = i - 1
st1.append(i)
while N[n + 1 - i] < N[n + 1 - st2[-1]]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR N... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
lis = list(map(int, input().split()))
summ = 0
i = 0
ans = []
while i < n:
wor = lis.copy()
peak = lis[i]
for j in range(i - 1, -1, -1):
if wor[j] > wor[j + 1]:
wor[j] = wor[j + 1]
for j in range(i, n - 1):
if wor[j] < wor[j + 1]:
wor[j + 1] = wor... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = [0] * N
for i in range(N):
t = [0] * N
t[i] = a[i]
for j in range(i, 0, -1):
t[j - 1] = min(t[j], a[j - 1])
for j in range(i, N - 1):
t[j + 1] = min(t[j], a[j + 1])
if sum(t) > sum(res):... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_C... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
x = list(map(int, input().split()))
dp, dp2, s, s2, d, d2 = [0] * n, [0] * n, [], [], {}, {}
for i in range(n):
if i == 0:
dp[0] = x[0]
elif x[i] >= x[i - 1]:
dp[i] = dp[i - 1] + x[i]
s.append(x[i - 1])
else:
while len(s) > 0 and x[i] < s[len(s) - 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR LIST LIST DICT DICT FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | def max_tower(n, a):
if n <= 2:
return sum(a), a
minn = 0
islin = True
isrev = True
for i in range(1, n):
if a[i] < a[i - 1]:
islin = False
elif a[i] > a[i - 1]:
isrev = False
if a[i] < a[minn]:
minn = i
if islin or isrev:
... | FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR IF VA... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
l = [int(i) for i in input().split()]
best = 0
bestl = []
for i in range(n):
temp = [i for i in l]
res = l[i]
j = i - 1
while j >= 0:
temp[j] = min(temp[j], temp[j + 1])
res += temp[j]
j -= 1
j = i + 1
while j < n:
temp[j] = min(temp[j], temp[j - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR N... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
otv = [(0) for i in range(n)]
mx = 0
m = list(map(int, input().split()))
for s in range(n):
ans = [(0) for i in range(n)]
ans[s] = m[s]
i = s - 1
j = s + 1
while i >= 0 or j < n:
if i >= 0:
ans[i] = min(m[i], ans[i + 1])
if j < n:
ans[j] = min... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR... |
This is an easier version of the problem. In this version $n \le 1000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the comp... | n = int(input())
ar = list(map(int, input().split()))
perflo = 0
perli = []
for i in range(0, n):
flo = 0
li = [0] * n
li[i] = ar[i]
fron = ar[i]
flo += ar[i]
for j in range(i + 1, n):
if ar[j] >= fron:
li[j] = fron
flo += li[j]
else:
li[j] = a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER V... |
There is a trampoline park with $n$ trampolines in a line. The $i$-th of which has strength $S_i$.
Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.
If at the moment Pekora jumps on trampoline $i$, the trampoline will launch her to position $i + S_i$, a... | for rpt in range(int(input())):
trampoline_count = int(input())
trampolines = [int(x) for x in input().split()]
shadow_prefix = [(0) for x in range(trampoline_count)]
res = 0
current_fix = 0
for i in range(trampoline_count):
current_fix += shadow_prefix[i]
if trampolines[i] - cur... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR N... |
There is a trampoline park with $n$ trampolines in a line. The $i$-th of which has strength $S_i$.
Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.
If at the moment Pekora jumps on trampoline $i$, the trampoline will launch her to position $i + S_i$, a... | for _ in range(int(input())):
n = int(input())
dp = [0] * (n + 1)
l = list(map(int, input().split()))
for i in range(0, n):
if l[i] > 1:
r = min(2 + i, n)
dp[r] += 1
r = min(l[i] + 1 + i, n)
dp[r] -= 1
for i in range(0, n):
dp[i + 1] = ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER ASS... |
There is a trampoline park with $n$ trampolines in a line. The $i$-th of which has strength $S_i$.
Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.
If at the moment Pekora jumps on trampoline $i$, the trampoline will launch her to position $i + S_i$, a... | import sys
input = sys.stdin.readline
def getvalue(n, seg_el):
i = n + seg_el
ANS = 0
ANS = SEG[i]
i >>= 1
while i != 0:
ANS += SEG[i]
i >>= 1
return ANS
def updates(l, r, x):
L = l + seg_el
R = r + seg_el
while L < R:
if L & 1:
SEG[L] += x
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.