description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | n = int(input())
x = []
for i in range(n):
c, p = map(int, input().split())
x += [(p, c, i)]
k = int(input())
r = list(map(int, input().split()))
sm = 0
ans = []
x.sort(reverse=True)
for i in range(n):
count = x[i][0]
cost = x[i][1]
uk = x[i][2]
tm1 = -1
tm2 = 100000
for j in range(k):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR 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 LIST EXPR FUNC_CALL VAR NU... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | import sys
def bin_search(c, k, rs):
l, r = 0, k
while l < r:
mid = (l + r) // 2
if c == rs[mid][0]:
return mid
if c < rs[mid][0]:
r = mid
else:
l = mid + 1
return l
def solve(n, groups, k, rs):
groups.sort(key=lambda x: (-x[2], x[1... | IMPORT FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VA... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | n = int(input())
book = [None] * n
for i in range(n):
t = [int(i) for i in input().split(" ")]
book[i] = i, t[0], t[1]
k = int(input())
cap = [(i, int(c)) for i, c in enumerate(input().split(" "))]
cap.sort(key=lambda x: x[1])
book.sort(key=lambda x: x[1])
m = 0
s = 0
r = []
cand = []
j = 0
for i in range(k):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | def findSeat(seats, cap):
for i in range(len(seats)):
if cap <= seats[i][0]:
return i
return -1
n = int(input())
visitors = []
for i in range(n):
c, p = map(int, input().split(" "))
visitors.append([c, p, i])
visitors.sort(key=lambda x: x[1], reverse=True)
k = int(input())
seats = ... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | def main():
F = lambda: map(int, input().split())
n = int(input())
groups = [(list(F())[::-1] + [i]) for i in range(n)]
k = int(input())
tables = list(F())
tables = [[tables[i], i] for i in range(k)]
tables = sorted(tables)
groups = sorted(groups)
count = 0
SUM = 0
res = []
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER LIST VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN ... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | n = int(input())
s = []
for i in range(n):
c, p = map(int, input().split())
s.append((p, c, i))
z = s[:]
k = int(input())
m = list(map(int, input().split()))
s.sort()
s.reverse()
answ = 0
summ = 0
sisok = []
f = "lopata"
for i in range(n):
price = s[i][0]
col = s[i][1]
index = s[i][2]
zn = 10000... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR EXPR FUNC_C... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | class er:
def __init__(self, ci, pi, id):
self.c = ci
self.p = pi
self.id = id
def __lt__(self, other):
return self.p < other.p
def __str__(self):
return str(self.c) + "," + str(self.p) + "," + str(self.id)
n = int(input())
a = []
for i in range(n):
ci, pi = ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_C... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | n = int(input())
arr = []
for i in range(n):
arr.append(list(map(int, input().strip().split())) + [i + 1])
k = int(input())
tables = list(map(int, input().strip().split()))
arr.sort(key=lambda x: -x[1])
ans = []
vis = [(0) for i in range(k)]
for i in arr:
mini = float("inf")
temp = None
for j in range(k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR LIST BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUN... |
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests received by now. Each request is characterized by two numbers: c_{i} an... | from sys import stdin
input = stdin.readline
class Booking:
def __init__(self, number, people, cost):
self.number = number
self.people = people
self.cost = cost
self.table = None
def __str__(self):
return str(self.__dict__)
class Table:
def __init__(self, numb... | ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NONE FUNC_DEF RETURN FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CAL... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | n, m, k, q = map(int, input().split())
tr_min = [None for _ in range(n)]
tr_max = [None for _ in range(n)]
for _ in range(k):
row, col = map(int, input().split())
row = n - row
col -= 1
if tr_min[row] == None or col < tr_min[row]:
tr_min[row] = col
if tr_max[row] == None or col > tr_max[row]... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR NONE VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR N... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | import sys
n, m, k, q = [int(i) for i in sys.stdin.readline().split()]
indata = sys.stdin.readlines()
data = []
inf = 1 << 50
for i in range(k):
data.append(tuple([int(f) for f in indata[i].split()]))
data.sort()
chutes = [int(i) for i in indata[-1].split()]
chutes.sort()
nearch = [(0, 0)] * (m + 1)
for i in range... | IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | import sys
n, m, k, q = list(map(int, sys.stdin.readline().strip().split()))
T = [0] * k
for i in range(0, k):
T[i] = list(map(int, sys.stdin.readline().strip().split()))
T[i][1] = T[i][1] - 1
T[i][0] = T[i][0] - 1
T.sort()
b = list(map(int, sys.stdin.readline().strip().split()))
b.sort()
for i in range(0,... | IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | bn = 0
ar = []
def binSearchMax(number):
last = bn
first = 0
mid = (last + first) // 2
while last >= first:
if ar[mid] < number:
first = mid + 1
elif ar[mid] > number:
last = mid - 1
else:
return mid
mid = (last + first) // 2
if a... | ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR RETURN VAR ASSIGN VAR VAR... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | [n, m, k, q] = [int(w) for w in input().split()]
trs = [[(int(w) - 1) for w in input().split()] for _ in range(k)]
b = [(int(w) - 1) for w in input().split()]
b.sort()
b.append(b[-1])
br = bl = 0
er = []
el = []
for i in range(m):
if br < q and i > b[br]:
bl = br
br += 1
el.append(b[bl])
er.... | ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR ... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | def lsearch(arr, v):
if arr[0] > v:
return None
l = 0
r = len(arr) - 1
while r - l > 1:
m = (l + r) // 2
if arr[m] > v:
r = m
else:
l = m
if arr[r] <= v:
return arr[r]
return arr[l]
def rsearch(arr, v):
if arr[-1] < v:
... | FUNC_DEF IF VAR NUMBER VAR RETURN NONE ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR VAR RETURN VAR VAR RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR RETURN NONE ASSIGN VAR NUMBER ASSIG... |
You are on the island which can be represented as a $n \times m$ table. The rows are numbered from $1$ to $n$ and the columns are numbered from $1$ to $m$. There are $k$ treasures on the island, the $i$-th of them is located at the position $(r_i, c_i)$.
Initially you stand at the lower left corner of the island, at t... | def nearest(point):
l = 0
r = q
while r - l > 1:
mid = int((r + l) / 2)
if safe[mid] <= point:
l = mid
else:
r = mid
if safe[l] > point:
return [safe[l]]
elif l + 1 == q:
return [safe[l]]
else:
return [safe[l], safe[l + 1]]
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR VAR RETURN LIST VAR VAR IF BIN_OP VAR NUMBER VAR RETURN LIST VAR VAR RETURN LIST VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF NUMBER ASSIGN VAR FU... |
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... | def main():
n, m = map(int, input().split())
w = [(c == "*") for i in range(n) for c in input()]
nm = n * m
q = [
*[range(i, i + m) for i in range(0, nm, m)],
*[range(i, nm, m) for i in range(m)],
]
e = [1000] * nm
for f in (True, False):
for r in q:
v = 0... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FO... |
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... | import sys
n, m = list(map(int, input().split()))
s = [list(input()) for i in range(n)]
u = [[(-1) for i in range(m)] for j in range(n)]
d = [[(-1) for i in range(m)] for j in range(n)]
l = [[(-1) for i in range(m)] for j in range(n)]
r = [[(-1) for i in range(m)] for j in range(n)]
for i in range(m):
acum = 0
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR... |
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
s = [list(input().rstrip()) for _ in range(n)]
t = [([1000] * m) for _ in range(n)]
ok1 = [([0] * m) for _ in range(n)]
ok2 = [([0] * m) for _ in range(n)]
for i in range(n):
si = s[i]
c = 0
for j in range(m):
if si[j] == "*":
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FO... |
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... | from itertools import accumulate
def main():
n, m = map(int, input().split())
S = [list(str(input())) for _ in range(n)]
L = [([0] * m) for _ in range(n)]
R = [([0] * m) for _ in range(n)]
U = [([0] * m) for _ in range(n)]
D = [([0] * m) for _ in range(n)]
for i in range(n):
cnt = ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... | n, m = list(map(int, input().split()))
c = []
for j in range(n):
d = []
s = input()
for i in s:
d.append(i)
c.append(d)
a = []
b = []
e = []
g = []
for j in range(n):
k = [0] * m
e.append(k)
for j in range(n):
k = [0] * m
g.append(k)
dpu = []
for j in range(n):
k = [0] * m
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
p = [-1] + list(map(int, input().split()))
g = [[] for i in range(n)]
for i in range(n - 1):
g[i + 1].append(p[i + 1] - 1)
g[p[i + 1] - 1].append(i + 1)
cnt = [0] * n
stack = [(-1, 0)]
stack2 = [(-1, 0)]
while stack:
par, ver = stack.pop()
for to in g[ver]:
if par != to:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUM... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | class DFS:
def __init__(self):
self.G = []
self.leave_tree = []
def take_input(self):
k = int(input())
if k > 1:
graph = [(int(node) - 1) for node in input().split(" ")]
self.G = [[] for _ in range(len(graph) + 1)]
for i in range(len(graph)):... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
a = input().split()
A = [int(x) for x in a]
B = [[x, []] for x in range(1, n + 1)]
i = 0
for i in range(len(A)):
B[A[i] - 1][1].append(i + 2)
def merge(arr, l, m, r):
n1 = m - l + 1
n2 = r - m
L = [0] * n1
R = [0] * n2
for i in range(0, n1):
L[i] = arr[l + i]
for j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST VAR LIST VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN V... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
p = list(map(int, input().split()))
gr = [[] for i in range(n)]
for i in range(n - 1):
gr[p[i] - 1].append(i + 1)
q = [0]
after = []
i = 0
s = [(0) for i in range(n)]
used = set()
used.add(0)
while q:
cur = q.pop()
after.append(cur)
for el in gr[cur]:
if el not in used:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER VA... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
if n == 1:
print(1)
else:
p = list(map(int, input().split()))
children = []
for i in range(n):
children.append([])
for i in range(n - 1):
children[p[i] - 1].append(i + 1)
layers = [1] + [0] * (n - 1)
layer = [0]
num = 2
bylayer = []
while len(laye... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VA... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
if n == 1:
print(1)
else:
adj = [[] for i in range(n + 10)]
s = input().split()
for i in range(2, n + 1):
pi = int(s[i - 2])
adj[i].append(pi)
adj[pi].append(i)
num = 1
curr = [1]
nextcurr = []
disco = [1]
visited = {(1): True}
while num <... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | il_rozgalezien = int(input())
d = [0, 0] + [int(x) for x in input().split()]
slownik = {}
for i in range(2, il_rozgalezien + 1):
if d[i] in slownik:
slownik[d[i]].append(i)
else:
slownik[d[i]] = [i]
il_lisci = [0] * (il_rozgalezien + 1)
for i in range(il_rozgalezien, 1, -1):
if i not in slow... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
tr = {}
p = [int(s) for s in input().split()]
for i in range(n - 1):
if not tr.get(p[i] - 1):
tr[p[i] - 1] = []
tr[p[i] - 1].append(i + 1)
lc = [(-1) for i in range(n)]
def get_lc(i):
if lc[i] == -1:
if tr.get(i):
lc[i] = 0
for j in tr[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL ... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | s = input().split()
n = int(s[0])
arr = list(map(int, input().split()))
children = [[] for i in range(n + 1)]
for i, j in enumerate(arr):
if 1 < i + 2 <= n:
children[j].append(i + 2)
leaves = [0] * (n + 1)
for i in range(n, 0, -1):
if not children[i]:
leaves[i] = 1
else:
leaves[i] = ... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMB... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
fa = [0, 0] + list(map(int, input().split()))
delta = [0] * (n + 1)
suml = [0] * (n + 1)
for i in range(n, 0, -1):
if suml[i] == 0:
suml[i] = 1
delta[suml[i]] += 1
suml[fa[i]] += suml[i]
for i in range(1, n + 1):
delta[i] += delta[i - 1]
ans = 0
for i in range(1, n + 1):
whi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR ... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | n = int(input())
p = [0, 0] + [int(w) for w in input().split()]
d = [0] * (n + 1)
for i in range(n, 1, -1):
if d[i] == 0:
d[i] = 1
d[p[i]] += d[i]
if n == 1:
d[1] = 1
d = d[1:]
d.sort()
for i in range(n):
print(d[i], end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR ... |
There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.
A subtree of a junction $v$ is a set... | N = int(input())
if N == 1:
print(1)
exit()
temp = [int(x) for x in input().split()]
temp.insert(0, 0)
temp.insert(0, 0)
visited = [0] * (N + 1)
for i in range(N, 1, -1):
if not visited[i]:
visited[i] = 1
visited[temp[i]] += visited[i]
print(*sorted(visited[1:])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR 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 NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | import sys
input = sys.stdin.readline
n = int(input())
moves = []
for i in range(n):
a, b = map(int, input().split())
moves.append((b, a))
moves.sort()
user = 0
no = 0
for i in range(n):
m = moves[i]
if user < m[1]:
user = m[0]
no += 1
print(no) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | from sys import stdin
n = int(input())
lr = [list(map(int, stdin.readline().split())) for i in range(n)]
lr.sort(key=lambda x: x[1])
cnt = 1
idx = 1
l, r = lr[0]
while idx < n:
ll, rr = lr[idx]
if r < ll:
cnt += 1
r = rr
idx += 1
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
a = []
for _ in range(n):
x, y = map(int, input().split())
a.append((x, y))
a = sorted(a, key=lambda y: (y[0], y[1] - y[0]))
prev = 0, 0
orders = 0
for order in a:
s, e = order
if s > prev[1]:
prev = order
orders += 1
elif e < prev[1]:
prev = order
print(orde... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR N... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | a = int(input())
b = []
total = 0
for i in range(a):
x, y = list(map(int, input().split()))
b.append([x, y])
b.sort(key=lambda x: x[1])
ending = 0
for i in b:
if i[0] > ending:
total += 1
ending = i[1]
print(total) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FU... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
L = []
r = []
m = []
for i in range(n):
ch = input()
L = [int(i) for i in ch.split()]
l = L[0]
r = L[1]
m.append((r, l))
m.sort()
x = m[0][0]
nb = 1
for i in range(1, n):
if m[i][1] > x:
x = m[i][0]
nb += 1
print(nb) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBE... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | orders = []
for _ in range(int(input())):
l, r = map(int, input().split())
orders.append([l, r])
orders.sort()
count = 0
while len(orders) > 1:
if orders[-2][0] == orders[-1][0]:
orders.pop(-2) if orders[-2][1] > orders[-1][1] else orders.pop(-1)
elif orders[-2][1] >= orders[-1][0]:
orde... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR VAR NUMBER NUMBER VAR NUMBER NUMBER FUNC_CALL VAR NUM... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def __starting_point():
n = int(input())
orders = []
for _ in range(n):
a, b = list(map(int, input().split()))
orders.append((b, a))
sorders = sorted(orders)
cnt = 0
now = 1
for i in range(0, len(sorders)):
if sorders[i][1] > now or i == 0:
cnt += 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VA... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def key_tri(argument):
return argument[1]
n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
L.sort(key=key_tri)
r = 1
t = L[0][1]
for k in range(1, n):
if L[k][0] > t:
r += 1
t = L[k][1]
print(r) | FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXP... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def f(x):
return x[1]
n = int(input())
L = []
for i in range(n):
order = [int(s) for s in input().split()]
L.append(order)
L = sorted(L, key=f)
last = [L[0][1]]
item = 1
while item < n:
while item < n - 1 and (L[item][1] <= last[-1] or L[item][0] <= last[-1]):
item += 1
if L[item][1] > las... | FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR V... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
l = []
for i in range(n):
s = input()
temp = s.split()
temp1 = [int(i) for i in temp]
l.append(temp1)
l = sorted(l, key=lambda x: x[1])
cnt = 1
prev = l[0][1]
for i in range(1, len(l)):
if l[i][0] > prev:
cnt = cnt + 1
prev = l[i][1]
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | import sys
from sys import stdin, stdout
def R():
return map(int, stdin.readline().strip().split())
arr = []
for h in range(int(stdin.readline().strip())):
arr.append(list(R()))
arr.sort(key=lambda x: x[1])
s, d = 0, 0
for i in arr:
if i[0] > d:
s += 1
d = i[1]
stdout.write(str(s)) | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
a = []
for i in range(n):
x, y = list(map(int, input().split()))
a.append((y, x))
a.sort()
cnt = 0
cur = -10
i = 0
while i < n:
if cur < a[i][1]:
cur = a[i][0]
cnt += 1
i += 1
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NU... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | ints = lambda: list(map(int, input().split()))
rd = lambda: input()
n = ints()[0]
A = []
for i in range(n):
l, r = ints()
A.append((r, r - l))
A.sort()
cnt, ct = 0, 0
for p in A:
if ct + p[1] > p[0]:
continue
else:
ct = p[0] + 1
cnt += 1
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VA... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
data = []
for num in range(n):
t = input()
l, r = t.split(" ")
l = int(l)
r = int(r)
data.append((l, r))
data = sorted(data, key=lambda s: s[1])
num = 1
ci = data[0]
for item in data:
il, ir = item
cl, cr = ci
if il > cr:
ci = item
num += 1
print(num) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR A... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
max_r = -(10**10)
ans = 0
for l, r in a:
if l > max_r:
ans += 1
max_r = r
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def solve(tasks):
if not tasks:
return 0
tasks.sort(key=lambda x: x[1])
curr = tasks[0][1]
count = 1
for i in range(1, len(tasks)):
if tasks[i][0] > curr:
curr = tasks[i][1]
count += 1
return count
n = int(input())
tasks = []
for _ in range(n):
task ... | FUNC_DEF IF VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
lis = []
for i in range(n):
a, b = map(int, input().split())
lis.append([b, a])
lis.sort()
ans = 1
l = lis[0][1]
h = lis[0][0]
for i in range(1, n):
if lis[i][1] > h:
h = lis[i][0]
ans += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
end = []
while n != 0:
l, r = map(int, input().split())
end += [[l, r]]
n -= 1
def Second(i):
return i[1]
end.sort(key=Second)
count = 1
k = 1
last = end[0][1]
while k != len(end):
if end[k][0] > last:
count += 1
last = end[k][1]
k += 1
print(count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST LIST VAR VAR VAR NUMBER FUNC_DEF RETURN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR NUMB... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
q = []
for i in range(n):
l, r = [int(x) for x in input().split()]
q.append([r, l])
q.sort()
prev, ans = 0, 0
for i in range(n):
start = q[i][1]
end = q[i][0]
if start > prev:
ans += 1
prev = end
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR VAR NUMBE... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def main():
res = t = 0
for r, l in sorted(
tuple(map(int, reversed(input().split()))) for _ in range(int(input()))
):
if t < l:
t = r
res += 1
print(res)
def __starting_point():
main()
__starting_point() | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
A = [0] * n
for i in range(n):
A[i] = tuple(map(int, input().split()))
A.sort(key=lambda x: x[1])
now, res = 0, 0
for i in range(n):
if A[i][0] > now:
now = A[i][1]
res += 1
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER EXPR F... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
array = []
for k in range(n):
a = list(map(int, input().split()))
array.append((a[1], a[0]))
array.sort()
c = 1
end = array[0][0]
for k in range(1, n):
if array[k][1] > end:
c += 1
end = array[k][0]
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
a = []
for i in range(n):
a.append(tuple(reversed(list(map(int, input().split())))))
a.sort()
c = 0
ans = 0
for i in range(n):
if c < a[i][1]:
c = a[i][0]
ans += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUM... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | times = []
for _ in range(int(input())):
a, b = list(map(int, input().split()))
times.append([a, b])
times.sort()
times = times[-1::-1]
a, b = times[0][0], times[0][1]
cnt = 1
for i in range(1, len(times)):
cur = times[i]
start, end = cur[0], cur[1]
if start < a and end < a:
cnt += 1
... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def snd(lst):
return lst[1]
n = int(input())
l = []
for i in range(0, n):
l.append([int(i) for i in input().split()])
l.sort(key=snd)
e = 0
ans = 0
for p in l:
if p[0] > e:
ans += 1
e = p[1]
print(ans) | FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
l = []
for i in range(n):
a, b = list(map(int, input().split()))
l.append([a, b])
l.sort(key=lambda x: x[1])
c = t = 0
for i in range(len(l)):
if t < int(l[i][0]):
t = int(l[i][1])
c += 1
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN V... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | r = lambda: map(int, input().split())
(n,) = r()
a = sorted(tuple(r()) for _ in range(n))[::-1]
ret, left = 0, 10**9 + 1
for l, r in a:
if r < left:
ret += 1
left = l
print(ret) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
rg = []
for i in range(n):
a, b = map(int, input().split())
rg.append((a, b))
rg.sort()
last = rg[0][1]
ans = 1
for i in rg[1:]:
if i[0] > last:
last = i[1]
ans += 1
elif i[1] < last:
last = i[1]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR A... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | cin = lambda: map(int, input().split())
(n,) = cin()
a = []
count = 1
for i in range(0, n):
a.append(tuple(list(cin())[::-1]))
a.sort()
ref = a[0][0]
for i in range(1, len(a)):
if a[i][1] > ref:
count += 1
ref = a[i][0]
print(count) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR N... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
lst = [[0, 0] for i in range(n)]
for i in range(n):
lst[i][1], lst[i][0] = map(int, input().split())
lst.sort()
last = 0
cnt = 0
for k in lst:
if k[1] > last:
last = k[0]
cnt += 1
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER EXPR F... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | import sys
input = sys.stdin.buffer.readline
n = int(input())
arr = []
for i in range(n):
l, r = map(int, input().split())
arr.append([l, r])
arr.sort()
count = -1
arr.append([1000000000000, 100000000000000])
mini = -1
for i in range(n + 1):
l, r = arr[i]
if l > mini:
count += 1
mini = ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NU... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
main = []
for i in range(n):
s, e = map(int, input().split())
main.append((s, e))
main.sort(key=lambda x: x[1])
cs, ce = main[0][0], main[0][1]
count = 1
for s, e in main[1:]:
if ce < s:
count += 1
cs = s
ce = e
print(count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR ... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | s = d = 0
t = [list(map(int, input().split())) for i in range(int(input()))]
for l, r in sorted(t, key=lambda q: q[1]):
if l > d:
s, d = s + 1, r
print(s) | ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | import sys
t = int(sys.stdin.readline())
l = []
for i in range(t):
l.append(list(map(int, sys.stdin.readline().rsplit())))
lst = sorted(l, key=lambda x: x[1])
a = -1
count = 0
for i in lst:
if i[0] > a:
a = i[1]
count += 1
print(count) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | from sys import stdin
n = int(input())
a = lambda: stdin.readline().split()
lst = sorted([[*map(int, input().split())] for _ in range(n)], key=lambda x: x[1])
res, last = 0, 0
for i, (x, y) in enumerate(lst):
if last < x:
last = y
res += 1
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | import sys
k = 0
s = []
for line in sys.stdin:
if k == 0:
n = int(line)
else:
l, r = map(int, line.split())
s.append((l, r))
k += 1
s.sort(key=lambda x: x[1])
max_r = 0
r = 0
for i in s:
if i[0] > max_r:
r += 1
max_r = i[1]
print(r) | IMPORT ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_... |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | n = int(input())
t = [list(map(int, input().split(" "))) for i in range(n)]
last = 0
count = 0
for i in sorted(t, key=lambda x: x[1]):
if last < i[0]:
last = i[1]
count += 1
print(count) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values β the start time l_{i} and the finish time r_{i} (l_{i} β€ r_{i}).
Restaurant management can accept and reject orders. What is the maximal number of... | def main():
tt = list(tuple(map(int, input().split())) for _ in range(int(input())))
tt.sort(key=lambda e: e.__getitem__(1))
res = t = 0
for l, r in tt:
if t < l:
t = r
res += 1
print(res)
def __starting_point():
main()
__starting_point() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = [(a, ind) for ind, a in enumerate(A)]
B.sort()
DP = [0] * (n + 1)
for i in range(3, n - 2):
DP[i] = max(DP[i - 1], DP[i - 3] + B[i][0] - B[i - 1][0])
MAX = max(DP)
x = DP.index(MAX)
REMLIST = []
while x > 0:
if DP[x]... | 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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR ... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | import sys
from sys import stdin
n = int(stdin.readline())
ao = list(map(int, stdin.readline().split()))
ai = [(ao[i], i) for i in range(n)]
ai.sort()
a = [ai[i][0] for i in range(n)]
dp = [([float("inf")] * 3) for i in range(n + 1)]
pp = [[0, 1, 2] for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
if dp[i + ... | 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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN V... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
a = sorted((int(v), i) for i, v in enumerate(input().split()))
INF = 10**18
dp = [-INF, -INF, 0]
for i in range(n - 1):
dp.append(max(dp[-1], dp[i] + a[i + 1][0] - a[i][0]))
cur, t = n - 1, 1
o = [0] * n
while cur >= 0:
if dp[cur] == dp[cur - 1]:
o[a[cur][1]] = t
cur -= 1
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMB... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | def solve_ee(ls):
dp = [float("inf")] * (len(ls) + 1)
dp[0] = 0
p = [0] * (len(ls) + 1)
for i in range(len(ls)):
for j in range(3, len(ls)):
if j <= 5 and i + j <= len(ls):
diff = ls[i + j - 1][0] - ls[i][0]
if dp[i + j] > dp[i] + diff:
... | FUNC_DEF ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
pre = [0] * (n + 1)
dp = [10**9] * (n + 1)
oa = [0] + list(map(int, input().split()))
a = sorted(oa)
ai = {}
for i in range(1, n + 1):
ai.setdefault(oa[i], []).append(i)
mapping = {}
for i in range(1, n + 1):
mapping[i] = ai[a[i]].pop()
dp[0] = 0
for i in range(3, n + 1):
for j in range(3, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
class SegmTree:
def __init__(self, size):
N = 1
while N < size:
N <<= 1
self.N = N
self.tree = [(float("inf"), -1)] * (2 * self.N)
def build(self):
for i in range(self.N - 1... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER BIN_OP NUMBER VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR B... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
aa = list(map(int, input().split()))
a = []
for i in range(n):
a.append([aa[i], i])
a.sort()
d = []
for i in range(n - 1):
d.append(a[i + 1][0] - a[i][0])
c = [(0) for i in range(n)]
i = 5
while i < n:
c[i] = max(c[i - 1], c[i - 3] + d[i - 3])
i += 1
i = n - 1
final = [(0) for k 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VA... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
inf = 10**18
a = sorted((v, i) for i, v in enumerate(map(int, input().split()))) + [(inf**2, -1)] * 5
dp = [0] + [inf] * (n + 10)
dpi = [-1] * (n + 10)
for i in range(n):
for j in range(i + 2, i + 5):
cost = a[j][0] - a[i][0]
if dp[j + 1] > dp[i] + cost:
dp[j + 1] = dp[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP LIST BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP ... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | import sys
def main():
n = int(input())
a = readIntArr()
a2 = [[x, i + 1] for i, x in enumerate(a)]
a2.sort(key=lambda x: x[0])
dp = [inf for _ in range(n)]
dp2 = [inf for _ in range(n)]
dp2i = [(-1) for _ in range(n)]
for i in range(2, min(n, 5)):
dp[i] = a2[i][0] - a2[0][0]
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUN... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
arr[i] = arr[i], i
arr.sort()
dp = [999999999999] * (n + 1)
dp[0] = 0
came_from = [-1] * (n + 1)
for i in range(n):
if i + 3 <= n:
if dp[i] + arr[i + 2][0] - arr[i][0] < dp[i + 3]:
came_from[i + 3] = i
dp[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | inf = float("inf")
def f(A, T):
dp = [0] * len(A)
for i in range(len(A) - 1, -1, -1):
if len(A) - i < 3:
dp[i] = inf
elif len(A) - i == 3:
dp[i] = A[i + 2][0] - A[i][0]
T[i] = len(A)
else:
extend = dp[i + 1] + (A[i + 1][0] - A[i][0])
... | ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
a = list(map(int, input().split()))
idx = sorted(range(n), key=lambda i: a[i])
a = sorted(a)
diff = [(x - y) for x, y in zip(a[1:], a[:-1])]
dp = [0] * (n - 1)
mask = [0] * (n - 1)
for i in range(n - 1):
if i < 2:
continue
if i <= n - 4:
add = 0 if i == 2 else dp[i - 3]
... | 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 FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_O... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
arr = sorted((v, i) for i, v in enumerate(map(int, input().split(" "))))
ans = [0] * n
if n == 3:
print(arr[2][0] - arr[0][0], 1)
for i in n:
ans[i] = i
elif n == 4:
print(arr[3][0] - arr[0][0], 1)
for i in n:
ans[i] = i
else:
INF = 1000000000000000000
dp = [0, I... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL ... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
x = list(map(int, input().split()))
y = []
for i in range(n):
y.append(x[i])
m = {}
inf = 885627645626577863562
for i in range(n):
m[x[i]] = i
x.sort()
dp, cnt, ans = [0] * n, [0] * n, [[] for i in range(n)]
dp[0] = dp[1] = inf
for i in range(2, n):
dp[i] = inf
for i2 in range(3, 6):
... | 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 VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER VAR B... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | def sort(n, a, b):
for i in range(n):
for j in range(i + 1, n):
if a[i] > a[j]:
t = a[i]
a[i] = a[j]
a[j] = t
t = pos[i]
pos[i] = pos[j]
pos[j] = t
n = int(input())
a = [0] + list(map(int, input().s... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input().strip())
order = dict()
nums = [(int(i), index) for index, i in enumerate(input().strip().split())]
nums.sort()
order = [i[1] for i in nums]
nums = [i[0] for i in nums]
dp = [(100000010000) for i in range(n + 1)]
dp[0] = 0
p = [(-1) for i in range(n + 1)]
for i in range(n + 1):
for j in range(3, 6):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
l = list(map(int, input().split()))
a = [[l[i], i] for i in range(n)]
a.sort()
ll = l.copy()
ll.sort()
if n < 6:
print(a[-1][0] - a[0][0], 1)
print(*([1] * n))
else:
b = [(ll[i] - ll[i - 1]) for i in range(3, n - 2)]
dp = [[0, 0] for i in range(len(b) + 5)]
i = len(b) - 1
dp[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 VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
a = list(map(int, input().split()))
a = sorted([(num, i) for i, num in enumerate(a)])
INF = 10**18
diff = a[-1][0] - a[0][0]
dp = [0] * (n + 1)
max_1 = 0
max_2 = 0
ind = []
for i in range(3, n - 2):
max_1 = max(max_1, dp[i - 2])
max_2 = max(max_2, dp[i])
tmp1 = a[i][0] - a[i - 1][0] + max_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 FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASS... |
There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^5$ students ready for the finals!
Each team should consist of at l... | n = int(input())
inp = input().split()
d = [(int(inp[i]), i) for i in range(n)]
d.sort()
mmm = d[-1][0] - d[0][0]
dif = [(d[i + 1][0] - d[i][0]) for i in range(n - 1)]
if n < 6:
print(sum(dif), 1)
print("1 " * n)
exit()
dp = [-1] * (n - 1)
dpp = [-1] * (n - 1)
ninf = -10000000000
dp[0] = ninf
dp[1] = ninf
d... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EX... |
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value $\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of elements at all.
-----Inpu... | INF = 10**18 + 179
[n, k], a = [list(map(int, input().split())) for x in range(2)]
a.sort()
dp, l = [([0] * (k - n % k + 1)) for x in range(n % k + 1)], n // k
for i in range(n % k + 1):
for j in range(k - n % k + 1):
pos = i * (l + 1) + j * l
dp[i][j] = (
min(
dp[i - 1][... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR FOR VAR FUNC_C... |
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value $\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of elements at all.
-----Inpu... | f = lambda: list(map(int, input().split()))
n, k = f()
p = sorted(f())
m, d = n // k, n % k
u, v = d + 1, k - d + 1
g = [0] * u * v
i = 0
for a in range(u):
j = a * m + a - 1
for b in range(v):
x = g[i - 1] + p[j] - p[j - m + 1] if b else 9000000000.0
y = g[i - v] + p[j] - p[j - m] if a else 900... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value $\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of elements at all.
-----Inpu... | inf = 10**10
n, k = map(int, input().split())
a = sorted(map(int, input().split()))
L, M = n // k, n % k
dp = [([0] * (k - M + 1)) for i in range(M + 1)]
for i in range(M + 1):
for j in range(k - M + 1):
pos = i * (L + 1) + j * L
dp[i][j] = (
min(
dp[i - 1][j] + a[pos - 1... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BI... |
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value $\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of elements at all.
-----Inpu... | def solve(n, k, As):
As.sort()
m, r = divmod(n, k)
dp = [0] * (r + 1)
for i in range(1, k):
im = i * m
new_dp = [0] * (r + 1)
new_dp[0] = dp[0] + As[im] - As[im - 1]
for h in range(1, min(i, r) + 1):
new_dp[h] = max(dp[h], dp[h - 1]) + As[im + h] - As[im + h -... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | class Traps:
def __init__(self, l, r, d):
self.before_l = l - 1
self.r = r
self.d = d
def qujianbingji(x, y):
if y[0] < x[0]:
if y[1] < x[0]:
return [y, x]
elif y[1] <= x[1]:
z = [y[0], x[1]]
return [z]
else:
retu... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN LIST VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR NUMBER VAR NUMBER RETURN LIST VAR RETURN LIST VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN LIST VAR AS... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | from sys import stdin
input = stdin.readline
m, n, k, t = map(int, input().split())
a = list(map(int, input().split()))
trap = []
def check(x):
avg = a[-x]
cost = n + 1
nr = 0
for i in range(k):
xx, y, d = trap[i]
if d <= avg:
continue
if y > nr:
cost +... | 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 FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR IF VAR VAR VAR BIN... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
m, n, k, t = list(map(int, input().split()))
A = list(map(int, input().split()))
T = [tuple(map(int, input().split())) for i in range(k)]
A.sort(reverse=True)
SLIST = [0] * (2 * 10**5 + 2)
ind = 0
for i in range(A[0], -1, -1):
SLIST[i] = SLIST[i + 1]
while ind < m and A[in... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP ... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
def checker(no):
pivot = agility[-no]
time = 0
squad = 0
captain = 0
for i in range(len(specs)):
if specs[i][2] <= pivot:
continue
elif captain < specs[i][0]:
time += specs[i][0] - 1 - squad + (captain - squad) * 2
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR IF VAR VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER ... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
M, N, K, T = map(int, input().split())
SOL = list(map(int, input().split()))
SOL = sorted(SOL, reverse=True)
traps = [list(map(lambda x: int(x), input().split())) for _ in range(K)]
traps = sorted(traps, key=lambda x: (x[0], x[1]))
lower = 0
high = M
w... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
M, N, K, T = map(int, input().split())
A = list(map(int, input().split()))
LRD = [list(map(int, input().split())) for _ in range(K)]
A.append(10**15)
A.sort(reverse=True)
l = 0
r = M + 1
while r - l > 1:
m = (r + l) // 2
D_limit = A[m]
P = [0] * (N + 2)
for L, R, D... | 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.