brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2096D - Wonderful Lightbulbs

We are given a final configuration of lit cells on an infinite integer grid. Initially, all cells are off except one hidden “origin” cell that was on at the beginning.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsmath
CF 2096F - Wonderful Impostors

We are given a game with n viewers, each of whom may either be a crewmate or an impostor. The viewers make statements about themselves and others in contiguous ranges.

codeforcescompetitive-programmingdata-structuresimplementationtwo-pointers
CF 2096E - Wonderful Teddy Bears

We are given a row of teddy bears, each colored either black or pink. A sequence of teddy bears is considered beautiful if all black bears appear to the left of all pink bears. Our goal is to transform any given arrangement into a beautiful one using the fewest possible moves.

codeforcescompetitive-programminggreedyimplementationsortings
CF 2096C - Wonderful City

We are given an $n times n$ grid where each cell contains an initial building height. We are allowed to modify the grid using two kinds of operations.

codeforcescompetitive-programmingdpimplementation
CF 2096B - Wonderful Gloves

We are given a collection of gloves in a drawer, where each glove has a color and a type: left or right. For each of the $n$ colors, we know exactly how many left gloves $li$ and right gloves $ri$ exist.

codeforcescompetitive-programminggreedymathsortings
CF 2096A - Wonderful Sticks

We are given a permutation task over the numbers from 1 to n. Each number represents a stick length, and every length must be used exactly once. The goal is to arrange these sticks in a sequence so that the relative constraints between consecutive positions are satisfied.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
Kvant Math Problem 325

Let $x_{n,m}$ be the entry in row $n$ and position $m$, where $0\le m\le n$.

kvantmathematicsolympiad
Kvant Math Problem 240

The examples suggest that divisions should be used together with repeated squaring.

kvantmathematicsolympiad
Kvant Math Problem 1481

Let $a=BC$, $b=CA$, $c=AB$.

kvantmathematicsolympiad
CF 2097F - Lost Luggage

We are dealing with a network of airports where lost luggage moves around according to daily flights and is partially recovered through inspections. Each airport has an initial number of lost luggage pieces.

codeforcescompetitive-programmingdpflows
Kvant Math Problem 360

Let

kvantmathematicsolympiad
Kvant Math Problem 371

Consider the problem on a $2\times 2$ chessboard first.

kvantmathematicsolympiad
Kvant Math Problem 1451

Let $d=\gcd(a,b)$ and write $a=dx$, $b=dy$ with $\gcd(x,y)=1$.

kvantmathematicsolympiad
CF 2098B - Sasha and the Apartment Purchase

We are given a line of houses indexed by large integers, and a multiset of bar positions along this line. Multiple bars can occupy the same house, but each bar is treated as a separate point.

codeforcescompetitive-programmingmathsortings
CF 2101D - Mani and Segments

We are given a permutation and asked to examine every contiguous segment of it. For each segment we compute two classical sequence measures: the length of its longest strictly increasing subsequence and the length of its longest strictly decreasing subsequence.

codeforcescompetitive-programmingdata-structuresimplementationsortingstwo-pointers
Kvant Math Problem 234

Alice moves on the integer lattice starting at $(0,0)$, and her motion is periodic, determined by a string of $n$ moves repeated indefinitely.

kvantmathematicsolympiad
CF 2101F - Shoo Shatters the Sunshine

We are given a tree with n vertices. Each vertex can be colored red, blue, or white. The "coolness" of a coloring is the largest distance between a red and a blue vertex. If there are no red or no blue vertices, the coolness is zero.

codeforcescompetitive-programmingcombinatoricsdptrees
CF 2101E - Kia Bakes a Cake

We are given a tree on $n$ vertices and a binary marker on each vertex that tells us whether that vertex is “active”. Only active vertices participate in the construction of a second structure: a complete weighted graph formed from these active nodes.

codeforcescompetitive-programmingdata-structuresdpgreedytrees
CF 2101C - 23 Kingdom

We are asked to maximize the "beauty" of an array derived from a given array a. For each position in a, the new array b must satisfy 1 ≤ bi ≤ ai. The beauty of b is the sum of the largest gaps between repeated occurrences of each value in b.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedyternary-searchtwo-pointers
CF 2101B - Quartet Swapping

We are given a permutation, which we can think of as a row of distinct numbered tiles. The only allowed move takes any block of four consecutive positions and swaps the first with the third and the second with the fourth, effectively turning a segment [ai, a{i+1}, a{i+2}…

codeforcescompetitive-programmingbrute-forcedata-structuresdivide-and-conquergreedysortings
CF 2101A - Mex in the Grid

We are asked to fill an $n times n$ grid with the integers from $0$ to $n^2 - 1$, each used exactly once. Every rectangular subgrid contributes a value equal to the MEX of the numbers inside it, and the objective is to maximize the sum of these MEX values over all possible…

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 2102B - The Picky Cat

We are given an array where each element has a fixed absolute value that is unique across the array. We are allowed to flip the sign of any elements independently any number of times.

codeforcescompetitive-programmingimplementationsortings
CF 2102A - Dinner Time

We are trying to construct an integer sequence of length $n$, where we are allowed to use negative values, such that two different constraints hold at the same time. First, the total sum of the entire sequence must equal a given value $m$.

codeforcescompetitive-programmingconstructive-algorithmsmath
Kvant Math Problem 924

Each pair of points is connected by a directed edge, so the structure is a tournament.

kvantmathematicsolympiad
CF 2103F - Maximize Nor

We are asked to process an array of integers where each integer fits in k bits. For each position in the array, we must find the maximum value of a "bitwise nor" over all subarrays that include that position.

codeforcescompetitive-programmingbitmasksdata-structuresdpimplementationsortings
CF 2103E - Keep the Sum

We are given an array of integers a where every element lies between 0 and k. The allowed operation is to pick two distinct indices i and j such that a[i] + a[j] = k, and then redistribute a value x from a[i] to a[j] (or vice versa) while ensuring both elements remain in the…

codeforcescompetitive-programmingconstructive-algorithmsimplementationtwo-pointers
CF 2103D - Local Construction

We are given, for each position in an unknown permutation, the iteration at which the element at that position disappears under a deterministic pruning process.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similarimplementationtwo-pointers
CF 2103C - Median Splits

We are given an array and asked whether we can cut it into three contiguous parts such that a particular condition involving medians holds across the cuts. If we pick two split points, the array is divided into three non-empty segments.

codeforcescompetitive-programmingbinary-searchgreedyimplementationsortings
CF 2103B - Binary Typewriter

We are given a binary string that we want to type using a very simple typewriter with only two keys, 0 and 1. At any moment, a finger rests on one of these two keys. Pressing the key under the finger outputs that character, while switching keys costs a separate operation.

codeforcescompetitive-programminggreedymath
CF 2103A - Common Multiple

We are given an array of positive integers and we want to select as many elements as possible while keeping their original order irrelevant since we are forming a subsequence.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 2104G - Modulo 3

We are given a functional graph, meaning each vertex has exactly one outgoing edge. This forms a combination of cycles and trees pointing into those cycles.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsugraphstrees
CF 2104F - Numbers and Strings

We are asked to count the number of distinct strings generated by a simple, but slightly tricky rule. For each integer $x$ from 1 up to $n$, we form a string by concatenating $x$ and $x+1$, then sorting the digits of this concatenation.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similardpimplementationmath
CF 2104E - Unpleasant Strings

We are given a fixed reference string s, and we are allowed to use only the first k lowercase letters. From this string s, we consider any string t to be “valid” if it can be formed by deleting characters from s without changing order, meaning t is a subsequence of s.

codeforcescompetitive-programmingbinary-searchdpgreedystrings
CF 2104D - Array and GCD

We are given an array of integers and we are allowed to modify it using a very specific resource system. Each increment of any element costs one coin, and each decrement of any element gives one coin.

codeforcescompetitive-programmingbinary-searchgreedymathnumber-theory
CF 2104A - Three Decks

We are given three stacks of cards arranged in a row, with the first stack containing a cards, the second b cards, and the third c cards. The numbers satisfy a < b < c.

codeforcescompetitive-programmingmath
CF 2104B - Move to the End

We are given an array of integers, and for every possible length $k$ from 1 to $n$, we want to maximize the sum of the last $k$ elements after moving one element of our choice to the end of the array. After we choose and move that element, we restore the array for the next query.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementation
CF 2104C - Card Game

We are given a small card game where each card is uniquely labeled from 1 to n, and each card initially belongs to either Alice or Bob. The ownership is fixed at the start, but during the game cards can move between players depending on outcomes.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgamesgreedymath
CF 2106G2 - Baudelaire (hard version)

We are given a tree with up to 1000 nodes, and each node hides a value of either 1 or −1. The tree is rooted somewhere, but the root is unknown to us.

codeforcescompetitive-programmingbinary-searchdfs-and-similardivide-and-conquerimplementationinteractivetrees
CF 2106G1 - Baudelaire (easy version)

We are given a tree of size $n$, where each node carries a value of either $1$ or $-1$. The tree is connected in such a way that every node is adjacent to node $1$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquergreedyinteractivetrees
CF 2106F - Goblin

We are asked to find the largest connected set of zeros in an $n times n$ grid that is built from a single binary string $s$. Each row of the grid is generated by flipping one character of $s$ at the row's index.

codeforcescompetitive-programmingdfs-and-similardpdsugreedymath
CF 2106E - Wolf

We are given a permutation of numbers from 1 to n, and we need to answer many independent queries. Each query picks a subarray range $[l, r]$ and a target value $k$. We imagine performing the standard binary search process on that fixed range, even though the array is not sorted.

codeforcescompetitive-programmingbinary-searchgreedymath
CF 2106D - Flower Boy

We are given a sequence of flowers in a row, each with a numeric beauty value. Igor wants to collect a fixed number of flowers, exactly $m$, moving strictly left to right.

codeforcescompetitive-programmingbinary-searchdpgreedytwo-pointers
CF 2106B - St. Chroma

We are given a list that must be a permutation of numbers from 0 to n−1. As we reveal this permutation from left to right, we compute a running value: after each prefix, we take the smallest non-negative integer that is missing from that prefix.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2106A - Dr. TC

We are given a binary string s of length n, and we imagine creating n new strings by flipping exactly one bit of s in each position. The resulting strings are arranged as rows of an n × n board. Our goal is to count the total number of 1s on this board.

codeforcescompetitive-programmingbrute-forcemath
CF 2106C - Cherry Bomb

We are given two arrays of length $n$, $a$ and $b$. Array $a$ is fully known, and $b$ has some missing elements marked as $-1$. The goal is to fill in the missing elements in $b$ such that the sum $ai + bi$ is constant for all $i$. Each element in $b$ must remain within $[0, k]$.

codeforcescompetitive-programminggreedymathsortings
CF 2107F2 - Cycling (Hard Version)

The problem presents a sequence of cyclists, each with an agility value. Leo is positioned at the back and wants to overtake all cyclists to reach the front.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpgreedy
Kvant Math Problem 865

For consecutive pairs $a_{i-1}<a_i$, the expression

kvantmathematicsolympiad
CF 2107F1 - Cycling (Easy Version)

We are given a line of cyclists with different “agility costs” associated to each position. Leo starts behind the last cyclist and wants to move all the way to the front, passing every cyclist one by one until he is ahead of the first.

codeforcescompetitive-programmingbinary-searchbrute-forcedpgreedy
CF 2107E - Ain and Apple Tree

We are asked to construct a rooted tree on nodes labeled from 1 to n, where node 1 is fixed as the root. The contribution of a pair of nodes i and j is determined by how deep their lowest common ancestor is in this rooted tree.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedymathtrees
CF 2107D - Apple Tree Traversing

We are given a tree with n nodes, each node initially containing one apple. Our goal is to traverse this tree and repeatedly select paths consisting only of nodes that still have apples, remove the apples along that path, and write down three numbers: the length of the path…

codeforcescompetitive-programmingbrute-forcedfs-and-similargreedyimplementationtrees
CF 2107C - Maximum Subarray Sum

We are given an array where some positions are already fixed and some positions are “unknown”. Unknown positions are initially set to zero, but we are allowed to overwrite them with arbitrary integers up to $10^{18}$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdpimplementationmath
CF 2107B - Apples in Boxes

We are given several independent games. In each game, there are multiple boxes of apples. On every move, a player removes exactly one apple from a single non-empty box.

codeforcescompetitive-programminggamesgreedymath
CF 2107A - LRC and VIP

We are given several independent arrays, and for each one we need to split its elements into two non-empty groups. Each number must go into exactly one group, so we are really choosing a binary labeling of indices.

codeforcescompetitive-programminggreedynumber-theory
CF 2108F - Fallen Towers

We are given an array of towers, each tower starting with some non-negative height. We must process every tower exactly once, in any order we choose.

codeforcescompetitive-programmingbinary-searchgreedy
CF 2108E - Spruce Dispute

We are given a tree with an odd number of vertices. Almost all vertices carry ornaments, and every ornament belongs to exactly one color, with each color appearing on exactly two vertices. One vertex is special and initially uncolored, acting as a “topper”.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsgreedyimplementationshortest-pathstrees
CF 2108D - Needle in a Numstack

We are given a hidden array C formed by concatenating two unknown arrays A and B. The split point is unknown. Both arrays are over the alphabet {1, 2, ...

codeforcescompetitive-programmingbinary-searchbrute-forceimplementationinteractive
CF 2108B - SUMdamental Decomposition

We are asked to construct an array of n positive integers whose bitwise XOR is exactly x and to minimize the sum of the array. Instead of outputting the array itself, we are asked to return the sum of the elements.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedyimplementationmath
CF 2108C - Neo's Escape

Neo is faced with a row of buttons, each labeled with a positive integer weight. He wants to press all the buttons such that the sequence of weights of the pressed buttons never increases.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpdsugraphsgreedyimplementation
CF 2108A - Permutation Warm-Up

We are given a permutation of the numbers from 1 to n, and we measure how far each element moves away from its original position. For each position i, we take the absolute difference between the value sitting there and i itself, and sum this over the entire array.

codeforcescompetitive-programmingcombinatoricsgreedymath
CF 2109F - Penguin Steps

We are working on an $n times n$ grid where each cell has two attributes: a weight $a{i,j}$ and a color that is either black or white. Two players start from different positions on the left side of the grid and both aim to reach the same exit cell on the rightmost column.

codeforcescompetitive-programmingbinary-searchdfs-and-similarflowsgraphsshortest-paths
CF 2109E - Binary String Wowee

We are given a binary string s of length n and an integer k. Our task is to perform exactly k operations, each of which selects a zero in the current string and flips all bits from the beginning up to that zero.

codeforcescompetitive-programmingcombinatoricsdpstrings
CF 2109C2 - Hacking Numbers (Medium Version)

In this problem, we are asked to manipulate an unknown integer $x$ to become equal to a given target $n$ using a very limited number of operations.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathnumber-theory
CF 2109C3 - Hacking Numbers (Hard Version)

We start with an unknown integer x, hidden from us, guaranteed to lie in the range from 1 to 10^9. Our goal is to transform this hidden value into a given target value n.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathnumber-theory
CF 2109D - D/D/D

We are given a connected, undirected graph with n vertices and m edges. There are no self-loops or multiple edges, so each edge connects two distinct vertices exactly once. Along with the graph, we are given a multiset A of positive integers, each representing a "move length.

codeforcescompetitive-programmingdfs-and-similargraphsgreedyshortest-paths
CF 2109C1 - Hacking Numbers (Easy Version)

In this problem, we face an unknown integer x that is initially hidden from us, and our goal is to transform it into a target integer n by issuing at most seven interactive commands.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsinteractivemathnumber-theory
CF 2109B - Slice to Survive

We are given a rectangular grid of size $n times m$, and a single token (a monster) initially placed at cell $(a, b)$.

codeforcescompetitive-programmingbitmasksgreedymath
CF 2109A - It's Time To Duel

We are given a line of players, each participating in duels with their immediate neighbor, so player 1 duels player 2, player 2 duels player 3, and so on until player $n-1$ duels player $n$. After all $n-1$ duels, each player reports whether they won at least one duel.

codeforcescompetitive-programmingimplementation
Kvant Math Problem 830

Let the first quadratic be $x^2 + p_1 x + q_1 = 0$ with two distinct real roots $r_1 \le s_1$.

kvantmathematicsolympiad
CF 2110F - Faculty

We are given an array of positive integers, and for each prefix of the array we are asked to compute its "beauty." The beauty of an array is defined as the maximum value of the function $f(x, y) = (x bmod y) + (y bmod x)$ over all pairs of elements $x, y$ in the prefix.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theory
CF 2110D - Fewer Batteries

We are asked to guide a robot through a series of checkpoints. Each checkpoint has a certain number of batteries that the robot can collect, and there are one-way passages connecting some checkpoints.

codeforcescompetitive-programmingbinary-searchdfs-and-similardpgraphsgreedyhashing
CF 2110E - Melody

We are asked to arrange a set of sounds, each defined by a volume and pitch, into a sequence that is simultaneously beautiful and non-boring.

codeforcescompetitive-programmingdfs-and-similargraphsimplementation
CF 2110C - Racing

We are asked to plan a drone flight through a sequence of obstacles, where each obstacle defines an allowable height range.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2110A - Fashionable Array

We are given an array of integers, and we define it as fashionable if the sum of its minimum and maximum elements is even. Our task is to determine the minimum number of elements that must be removed so that the array becomes fashionable.

codeforcescompetitive-programmingimplementationsortings
CF 2110B - Down with Brackets

We are given a string representing a balanced sequence of parentheses, and we need to decide whether it is possible to remove exactly one opening bracket and exactly one closing bracket such that the resulting string is no longer balanced.

codeforcescompetitive-programmingstrings
CF 2111G - Divisible Subarrays

We are given a permutation of the numbers from 1 to n. For every query, we take a contiguous segment of this permutation and must decide whether that segment has a very specific structural property: whether there exists a way to split the segment into two parts using a…

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcedata-structuresinteractive
CF 2111F - Puzzle

We are asked to construct a shape made from unit square tiles placed on the integer grid. Each tile occupies one cell, and all chosen cells must form a single 4-connected component, meaning you can walk between any two tiles by stepping across shared edges.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 2111E - Changing the String

We are given a string consisting only of the characters a, b, and c. Alongside it is a sequence of operations. Each operation suggests a possible replacement: choose any occurrence of a letter x and turn it into another letter y, or skip the operation entirely.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementationsortingsstrings
CF 2111D - Creating a Schedule

We are tasked with creating a class schedule for a faculty where each group has exactly six classes on the first day. There are $n$ student groups and $m$ classrooms.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementationsortings
CF 2111B - Fibonacci Cubes

We have a collection of cubes, where the side length of the $i$-th cube corresponds to the $i$-th Fibonacci number under a modified definition: $f1 = 1$, $f2 = 2$, and $fi = f{i-1} + f{i-2}$ for $i 2$.

codeforcescompetitive-programmingbrute-forcedpimplementationmath
CF 2111A - Energy Crystals

We are working with three identical storage units that start at zero energy. The goal is to bring all three to exactly the same target level $x$. The only operation allowed is to pick one unit and increase its value by any positive integer.

codeforcescompetitive-programminggreedyimplementationmath
CF 2111C - Equal Values

We are given an array of integers and allowed to repeatedly “broadcast” a chosen element’s value either to everything on its left or everything on its right.

codeforcescompetitive-programmingbrute-forcegreedytwo-pointers
CF 2112F - Variables and Operations

We are given a directed system of value propagation rules over $n$ variables. Each rule says that one variable $x$ can potentially be reduced using the value of another variable $y$, shifted by a constant $z$, through an operation of the form $ax leftarrow min(ax, ay + z)$.

codeforcescompetitive-programminggraphsgreedyshortest-paths
CF 2112E - Tree Colorings

We are given a rooted tree, and every vertex must be assigned one of three colors: green, blue, or yellow. The root is fixed to be green. A coloring is considered valid when two connectivity constraints hold.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpgraphsmathnumber-theorytrees
CF 2112D - Reachability and Tree

We are asked to take an undirected tree and assign a direction to each edge so that the number of ordered vertex pairs $(u, v)$ where there is a directed path from $u$ to $v$ equals exactly $n$, the number of vertices.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphstrees
Kvant Math Problem 734

Let $AB=c$, $AC=b$, and let $\angle A = \alpha$.

kvantmathematicsolympiad
CF 2112C - Coloring Game

We are given a sorted array of integers, and we need to count how many ways Alice can pick exactly three distinct indices such that no matter what Bob does afterward, Alice’s chosen triple is “safe”. The sequence of events matters. Alice first selects three elements.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedytwo-pointers
CF 2112A - Race

In this problem, Alice and Bob are racing to a prize that will appear at one of two distinct points on a one-dimensional line. Alice has already chosen her starting point a.

codeforcescompetitive-programmingimplementationmath
CF 2112B - Shrinking Array

We are given an array of integers, and we want to make it "beautiful." A beautiful array has at least two elements and contains at least one pair of adjacent elements whose difference is at most one.

codeforcescompetitive-programmingbrute-forcegreedy
CF 2113E - From Kazan with Love

We are given a tree representing a city. Marat starts at vertex x at time 1 and wants to reach vertex y. Each day progresses in discrete time steps, and at each step he can either stay in place or move along one edge of the tree. At the same time, there are up to 200 enemies.

codeforcescompetitive-programmingdfs-and-similargraphsimplementationtrees
CF 2113F - Two Arrays

We are given two arrays, a and b, each containing n integers. We can swap elements between the arrays at the same index as many times as we like. The goal is to maximize the sum of the number of distinct elements in each array.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsmath
CF 2113D - Cheater

We are given two ordered stacks of cards, one belonging to the player and one belonging to the dealer. Both stacks contain distinct values, and each stack is played from top to bottom. In every round, both sides reveal their current top card.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedyimplementation
CF 2113C - Smilo and Minecraft

We are given a grid where each cell is either empty, stone, or gold. Smilo can only place dynamite in empty cells. When he detonates at an empty cell, it affects a square region centered there with fixed radius k, so the square has side length 2k + 1.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 2113B - Good Start

We are given a rectangular roof aligned with the coordinate axes, with width $w$ and height $h$. The roof lies in the plane starting from $(0,0)$. We also have identical rectangular tiles of fixed size $a times b$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2113A - Shashliks

We are given a grill that starts at some temperature and two types of shashlik that can be cooked repeatedly without limit. Each time we cook a portion, we must first check whether the current temperature is high enough, and then the grill’s temperature drops afterward.

codeforcescompetitive-programminggreedymath
CF 2114G - Build an Array

We start from an empty array and repeatedly append integers either to its left end or right end. After each insertion, the array may simplify itself: whenever two identical neighbors appear, they merge into a single element equal to their sum.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpgreedymathnumber-theory
CF 2114F - Small Operations

We are given two integers, x and y, and an upper bound k. Our goal is to transform x into y using the fewest possible operations.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similardpmathnumber-theorysortings
CF 2114E - Kirei Attacks the Estate

We are given a rooted tree where vertex 1 is the root, and each vertex has a numeric value. For every vertex $v$, we consider the path going upward from $v$ to the root.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 2114D - Come a Little Closer

We are asked to destroy all monsters on a very large $10^9 times 10^9$ grid. Each monster occupies a distinct cell, and we are allowed to move exactly one monster to any empty cell before selecting a rectangle that covers some contiguous region of the grid.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 2114C - Need More Arrays

We are given a non-decreasing array of integers. The task is to remove zero or more elements to maximize the number of arrays formed according to a sequential rule.

codeforcescompetitive-programmingdpgreedy
CF 2114B - Not Quite a Palindromic String

We are given a binary string of even length and a target number of good pairs. A good pair consists of two characters symmetrically positioned around the center that are equal.

codeforcescompetitive-programminggreedymath