
Frog Jumping
A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it […]
A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it […]
You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. You will perform $q$ operations. In the $i$-th operation, you have a symbol […]
You are planning to build housing on a street. There are $n$ spots available on the street on which you can build a house. The […]
You are given a rooted tree with $n$ nodes, labeled from $1$ to $n$. The tree is rooted at node $1$. The parent of the […]
You are given a set of $n$ points in a 2D plane. No three points are collinear. A pentagram is a set of $5$ points […]
We have three positive integers $a$, $b$ and $c$. You don’t know their values, but you know some information about them. Consider all three pairwise sums, i.e. […]
Everyone knows that two consecutive (adjacent) “minus” signs can be replaced with a single “plus” sign. You are given the string $s$, consisting of “plus” […]
Polycarp is developing a method for transmitting $n$ integer sequences over a network. This method should support the transmission of an arbitrary number of integer […]
Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress […]
You are given the sequence $a_1, a_2, \dots, a_n$. You can choose any subset of elements and then reorder them to create a “saw”. The […]
You are given an undirected graph consisting of $n$ vertices and $m$ edges. Recall that a cycle is a path that starts and ends in […]
You are given $n$ segments on the $Ox$ axis. The $i$-th segment is given as a pair $l_i, r_i$, where $l_i$ is the position of […]
Let’s call a string good if and only if it consists of only two types of letters — ‘a’ and ‘b’ and every two consecutive letters are distinct. […]
You are given a permutation $p$ of integers from $1$ to $n$, where $n$ is an even number. Your goal is to sort the permutation. […]
Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of […]
You are given $n$ pairs of integers $(a_1, b_1), (a_2, b_2), \ldots, (a_n, b_n)$. All of the integers in the pairs are distinct and are […]
You are given $n$ objects. Each object has two integer properties: $val_i$ — its price — and $mask_i$. It is guaranteed that the sum of all prices […]
There are $n$ stones arranged on an axis. Initially the $i$-th stone is located at the coordinate $s_i$. There may be more than one stone […]