problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 ⌀ | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
D. Flip and Reversetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string s of 0's and 1's. You are allowed to perform the following operation: choose a non-empty contiguous substring of s that contains an equal number of 0's and 1's; flip all charac... | 3
100101
1100011
10101010
| 010110 0110110 10101010 | 2 seconds | 512 megabytes | ['data structures', 'graphs', 'greedy', '*3100'] |
C. Latin Squaretime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a square matrix of size n. Every row and every column of this matrix is a permutation of 1, 2, \ldots, n. Let a_{i, j} be the element at the intersection of i-th row and j-th column for eve... | 5
3 2
1 2 3
2 3 1
3 1 2
DR
3 2
1 2 3
2 3 1
3 1 2
LU
3 1
1 2 3
2 3 1
3 1 2
I
3 1
1 2 3
2 3 1
3 1 2
C
3 16
1 2 3
2 3 1
3 1 2
LDICRUCILDICRUCI
| 2 3 1 3 1 2 1 2 3 3 1 2 1 2 3 2 3 1 1 2 3 3 1 2 2 3 1 1 3 2 2 1 3 3 2 1 2 3 1 3 1 2 1 2 3 | 2 seconds | 512 megabytes | ['math', 'matrices', '*2700'] |
B. Glass Half Spilledtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n glasses on the table numbered 1, \ldots, n. The glass i can hold up to a_i units of water, and currently contains b_i units of water.You would like to choose k glasses and collect as mu... | 3
6 5
6 5
10 2
| 7.0000000000 11.0000000000 12.0000000000 | 2 seconds | 512 megabytes | ['dp', '*2000'] |
A. Row GCDtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two positive integer sequences a_1, \ldots, a_n and b_1, \ldots, b_m. For each j = 1, \ldots, m find the greatest common divisor of a_1 + b_j, \ldots, a_n + b_j.InputThe first line contains two ... | 4 4
1 25 121 169
1 2 7 23
| 2 3 8 24 | 2 seconds | 512 megabytes | ['math', 'number theory', '*1600'] |
E. XOR-rangestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven integers c_{0}, c_{1}, \ldots, c_{k-1} we can define the cost of a number 0 \le x < 2^{k} as p(x) = \sum_{i=0}^{k-1} \left( \left\lfloor \frac{x}{2^{i}} \right\rfloor \bmod 2 \right) \cdot c_{i}. In ... | 4 3
3 3
5 5
6 6
1 1
5 2 7
| 30 | 2 seconds | 256 megabytes | ['dp', 'greedy', '*3500'] |
G. Forbidden Valuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is editing a complicated computer program. First, variable x is declared and assigned to 0. Then there are instructions of two types: set y v — assign x a value y or spend v burles to remov... | 5 1
set 1 10
set 2 15
if 2
set 1 7
end
| 17 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*2900'] |
F. String and Operationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of n characters. These characters are among the first k lowercase letters of the Latin alphabet. You have to perform n operations with the string.During the i... | 6
4 2
bbab
7 5
cceddda
6 5
ecdaed
7 4
dcdbdaa
8 3
ccabbaca
5 7
eabba
| aaaa baccacd aabdac aabacad aaaaaaaa abadb | 2 seconds | 256 megabytes | ['dp', 'greedy', '*2800'] |
E. Four Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four different integer points p_1, p_2, p_3 and p_4 on \mathit{XY} grid.In one step you can choose one of the points p_i and move it in one of four directions by one. In other words, if you ... | 3
0 2
4 2
2 0
2 4
1 0
2 0
4 0
6 0
1 6
2 2
2 5
4 1
| 8 7 5 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'flows', 'geometry', 'greedy', 'implementation', 'math', 'ternary search', '*2400'] |
D. Sequence and Swapstime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a sequence a consisting of n integers a_1, a_2, \dots, a_n, and an integer x. Your task is to make the sequence a sorted (it is considered sorted if the condition a_1 \le a_2 \le a_... | 6
4 1
2 3 5 4
5 6
1 1 3 4 4
1 10
2
2 10
11 9
2 10
12 11
5 18
81 324 218 413 324
| 3 0 0 -1 1 3 | 1.5 seconds | 512 megabytes | ['dp', 'greedy', 'sortings', '*1600'] |
C. Ping-pongtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob play ping-pong with simplified rules.During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Therea... | 3
1 1
2 1
1 7
| 0 1 1 1 0 7 | 1 second | 256 megabytes | ['constructive algorithms', 'games', 'math', '*1100'] |
B. Jumpstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are standing on the \mathit{OX}-axis at point 0 and you want to move to an integer point x > 0.You can make several jumps. Suppose you're currently at point y (y may be negative) and jump for the k-th time. ... | 5
1
2
3
4
5
| 1 3 2 3 4 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1200'] |
A. Strange Functionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321) = 123, f(120... | 5
4
37
998244353
1000000007
12345678901337426966631415
| 1 2 9 10 26 | 2 seconds | 256 megabytes | ['math', 'number theory', '*800'] |
F. Array Partitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers.Let min(l, r) be the minimum value among a_l, a_{l + 1}, \ldots, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, \ldots, a_r.Your task is... | 6
11
1 2 3 3 3 4 4 3 4 2 1
8
2 9 1 7 3 9 4 1
9
2 1 4 2 4 3 3 1 2
7
4 2 1 1 4 1 4
5
1 1 1 1 1
7
4 3 4 3 3 3 4
| YES 6 1 4 NO YES 2 5 2 YES 4 1 2 YES 1 1 3 YES 2 1 4 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'two pointers', '*2100'] |
E. Number of Simple Pathstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and t... | 3
3
1 2
2 3
1 3
4
1 2
2 3
3 4
4 2
5
1 2
2 3
1 3
2 5
4 3
| 6 11 18 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'graphs', 'trees', '*2000'] |
D. Number into Sequencetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n (n > 1).Your task is to find a sequence of integers a_1, a_2, \ldots, a_k such that: each a_i is strictly greater than 1; a_1 \cdot a_2 \cdot \ldots \cdot a_k = n (i.... | 4
2
360
4999999937
4998207083
| 1 2 3 2 2 90 1 4999999937 1 4998207083 | 3 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1300'] |
C. Sequence Transformationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a, initially consisting of n integers.You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same elemen... | 5
3
1 1 1
5
1 2 3 4 5
5
1 2 3 2 1
7
1 2 3 1 2 3 1
11
2 2 1 2 3 2 1 2 3 1 2
| 0 1 1 2 3 | 1 second | 256 megabytes | ['greedy', 'implementation', '*1200'] |
B. Unique Bid Auctiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem).Let's simplify t... | 6
2
1 1
3
2 1 3
4
2 2 2 3
1
1
5
2 3 2 4 2
6
1 1 5 5 4 4
| -1 2 4 1 2 -1 | 1 second | 256 megabytes | ['implementation', '*800'] |
A. Special Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given one integer n (n > 1).Recall that a permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2, 3, 1, 5, 4] is a permutation... | 2
2
5
| 2 1 2 1 5 3 4 | 1 second | 256 megabytes | ['constructive algorithms', 'probabilities', '*800'] |
F. Even Hardertime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong is now developing a puzzle game. The puzzle consists of n platforms numbered from 1 to n. The player plays the game as a character that can stand on each platform and the goal of the game is to mo... | 3
4
1 1 1 0
5
4 3 2 1 0
9
4 1 4 2 1 0 2 1 0
| 0 3 2 | 2 seconds | 512 megabytes | ['dp', '*2700'] |
E. Dog Snackstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong is playing with his dog, Badugi. They're at a park that has n intersections and n-1 bidirectional roads, each 1 meter in length and connecting two intersections with each other. The intersections a... | 3
3
1 2
1 3
4
1 2
2 3
3 4
8
1 2
2 3
3 4
1 5
5 6
6 7
5 8
| 2 3 3 | 3 seconds | 512 megabytes | ['binary search', 'dfs and similar', 'dp', 'greedy', 'trees', '*2300'] |
D. Checkpointstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong is developing a game consisting of n stages numbered from 1 to n. The player starts the game from the 1-st stage and should beat the stages in increasing order of the stage number. The player wins ... | 4
1
2
8
12
| -1 1 1 4 1 1 1 1 5 1 1 0 1 1 | 1 second | 512 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', 'probabilities', '*1900'] |
C. Trianglestime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong has a square board consisting of n rows and n columns of square cells, each consisting of a single digit (from 0 to 9). The cell at the j-th column of the i-th row can be represented as (i, j), and ... | 5
3
000
122
001
2
57
75
4
0123
4012
3401
2340
1
9
8
42987101
98289412
38949562
87599023
92834718
83917348
19823743
38947912
| 4 4 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 9 6 9 9 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 49 49 49 49 15 0 30 42 42 | 3 seconds | 512 megabytes | ['greedy', 'implementation', '*1700'] |
B. Suffix Operationstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong has an interesting machine that has an array a with n integers. The machine supports two kinds of operations: Increase all elements of a suffix of the array by 1. Decrease all elements of a... | 7
2
1 1
3
-1 0 2
4
99 96 97 95
4
-3 -5 -2 1
6
1 4 3 2 4 1
5
5 0 0 0 5
9
-367741579 319422997 -415264583 -125558838 -300860379 420848004 294512916 -383235489 425814447
| 0 1 3 4 6 5 2847372102 | 1 second | 512 megabytes | ['constructive algorithms', 'implementation', '*1400'] |
A. Cancel the Trainstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputGildong's town has a train system that has 100 trains that travel from the bottom end to the top end and 100 trains that travel from the left end to the right end. The trains starting from each side ... | 3
1 2
1
3 4
3 2
1 3 4
2 4
9 14
2 7 16 28 33 57 59 86 99
3 9 14 19 25 26 28 35 41 59 85 87 99 100
| 0 1 3 | 1 second | 512 megabytes | ['implementation', '*800'] |
G. Game On Treetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. They have a tree consisting of n vertices. Initially, Bob has k chips, the i-th chip is located in the vertex a_i (all these vertices are unique). Before the game starts... | 5
2 4
3 1
3 4
3 5
2
4 5
| 2 1 2 0 0 | 3 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'greedy', 'trees', '*2700'] |
F. Divide Powerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a multiset of powers of two. More precisely, for each i from 0 to n exclusive you have cnt_i elements equal to 2^i.In one operation, you can choose any one element 2^l > 1 and divide it in... | 6 11
0 1 0 0 1 0
2 1 5
2 4 18
1 1 0
2 2 5
2 0 17
1 0 3
2 1 2
1 1 4
1 4 0
1 5 1
2 2 8
| 4 16 4 -1 0 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*2900'] |
E. Two Editorialstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland regional ICPC contest has just ended. There were m participants numbered from 1 to m, who competed on a problemset of n problems numbered from 1 to n.Now the editorial is about to take place. T... | 10 5 3
1 3
2 4
6 9
6 9
1 8
| 14 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'sortings', 'two pointers', '*2500'] |
D. Radio Towerstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n + 2 towns located on a coordinate line, numbered from 0 to n + 1. The i-th town is located at the point i.You build a radio tower in each of the towns 1, 2, \dots, n with probability \frac{1}... | 2
| 748683265 | 2 seconds | 512 megabytes | ['combinatorics', 'dp', 'math', '*1600'] |
C. Two Bracketstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of brackets of two types: '(', ')', '[' and ']'.A string is called a regular bracket sequence (RBS) if it's of one of the following types: empty string; '(' + RBS +... | 5
()
[]()
([)]
)]([
)[(]
| 1 2 2 0 1 | 1 second | 256 megabytes | ['greedy', '*800'] |
B. Toy Blockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are asked to watch your nephew who likes to play with toy blocks in a strange way.He has n boxes and the i-th box has a_i blocks. His game consists of two steps: he chooses an arbitrary box i; he tr... | 3
3
3 2 2
4
2 2 3 2
3
0 3 0
| 1 0 3 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'math', 'sortings', '*1400'] |
A. Robot Programtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an infinite 2-dimensional grid. The robot stands in cell (0, 0) and wants to reach cell (x, y). Here is a list of possible commands the robot can execute: move north from cell (i, j) to (i, j ... | 5
5 5
3 4
7 1
0 0
2 0
| 10 7 13 0 3 | 2 seconds | 256 megabytes | ['math', '*800'] |
F. Nullify The Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJeel and Ashish play a game on an n \times m matrix. The rows are numbered 1 to n from top to bottom and the columns are numbered 1 to m from left to right. They play turn by turn. Ashish goes firs... | 4
1 1
0
1 3
0 0 5
2 2
0 1
1 0
3 3
1 2 3
4 5 6
7 8 9
| Jeel Ashish Jeel Ashish | 2 seconds | 256 megabytes | ['constructive algorithms', 'games', '*2700'] |
E2. Bitwise Queries (Hard Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is the constraints on the number of queries.This is an interactive problem.Ridbit has a hidden array a of n integers which he wan... | 4
0
2
3
| OR 1 2 OR 2 3 XOR 2 4 ! 0 0 2 3 | 4 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'interactive', 'math', '*2300'] |
E1. Bitwise Queries (Easy Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is the constraints on the number of queries.This is an interactive problem.Ridbit has a hidden array a of n integers which he wan... | 4
0
2
3
| OR 1 2 OR 2 3 XOR 2 4 ! 0 0 2 3 | 4 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'interactive', 'math', '*2000'] |
D. Circle Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUtkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.Consider the 2D plane. There is a token which is initially at (0,0). In one m... | 5
2 1
5 2
10 3
25 4
15441 33
| Utkarsh Ashish Utkarsh Utkarsh Ashish | 2 seconds | 256 megabytes | ['games', 'geometry', 'math', '*1700'] |
C. String Equalitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish has two strings a and b, each of length n, and an integer k. The strings only contain lowercase English letters.He wants to convert string a into string b by performing some (possibly zero) ope... | 4
3 3
abc
bcd
4 2
abba
azza
2 1
zz
aa
6 2
aaabba
ddddcc
| No Yes No Yes | 2 seconds | 256 megabytes | ['dp', 'greedy', 'hashing', 'implementation', 'strings', '*1400'] |
B. Non-Substring Subsequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.A query is described by a pair of integers l_i, r_i (1 \leq l_i \lt r... | 2
6 3
001000
2 4
1 3
3 5
4 2
1111
1 4
2 3
| YES NO YES NO YES | 1 second | 256 megabytes | ['dp', 'greedy', 'implementation', 'strings', '*900'] |
A. Subtract or Dividetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRidbit starts with an integer n.In one move, he can perform one of the following operations: divide n by one of its proper divisors, or subtract 1 from n if n is greater than 1. A proper divisor ... | 6
1
2
3
4
6
9
| 0 1 2 2 2 3 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
H2. Multithreading (Hard Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions of the problem is that there are no updates in the easy version.There are n spools of thread placed on the rim of a circular table. The spoo... | 8 0
bwbb?www
| 1 | 4 seconds | 256 megabytes | ['combinatorics', 'implementation', 'math', '*3300'] |
H1. Multithreading (Easy Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions of the problem is that there are no updates in the easy version.There are n spools of thread placed on the rim of a circular table. The spoo... | 8 0
bwbb?www
| 1 | 4 seconds | 256 megabytes | ['combinatorics', 'fft', 'math', '*2900'] |
G. Communismtime limit per test1.5 secondsmemory limit per test32 megabytesinputstandard inputoutputstandard outputPlease pay attention to the unusual memory limit in this problem.In a parallel universe, Satan is called "Trygub". For that reason, the letters of his namesake were deleted from the alphabet in ancient tim... | 7 1 2
comicom
| 3 c m o | 1.5 seconds | 32 megabytes | ['bitmasks', 'dp', 'trees', '*3500'] |
F. The Struggling Contestanttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced... | 4
6
2 1 2 3 1 1
5
1 1 1 2 2
8
7 7 2 7 7 1 8 7
10
1 2 3 4 1 1 2 3 4 1
| 1 3 -1 2 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*2400'] |
E. Capitalismtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA society can be represented by a connected, undirected graph of n vertices and m edges. The vertices represent people, and an edge (i,j) represents a friendship between people i and j.In society, the i-th ... | 6 6
1 2 0
3 2 0
2 5 0
6 5 1
6 3 0
2 4 1
| YES 3 3 2 1 3 1 0 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'shortest paths', '*2700'] |
D. Rating Compressiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the competitive programming platform CodeCook, every person has a rating graph described by an array of integers a of length n. You are now updating the infrastructure, so you've created a progr... | 5
5
1 5 3 4 2
4
1 3 2 1
5
1 3 3 3 2
10
1 2 3 4 5 6 7 8 9 10
3
3 3 2
| 10111 0001 00111 1111111111 000 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'implementation', 'two pointers', '*1800'] |
C2. Errich-Tac-Toe (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version.Errichto gave Monogon the following challenge in order to i... | 3
3
.O.
OOO
.O.
6
XXXOOO
XXXOOO
XX..OO
OO..XX
OOOXXX
OOOXXX
5
.OOO.
OXXXO
OXXXO
OXXXO
.OOO.
| .O. OXO .O. OXXOOX XOXOXO XX..OO OO..XX OXOXOX XOOXXO .OXO. OOXXO XXOXX OXXOO .OXO. | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*2300'] |
C1. Errich-Tac-Toe (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is that tokens of type O do not appear in the input of the easy version.Errichto gave Monogon the following challenge in order to i... | 3
3
.X.
XXX
.X.
6
XX.XXX
XXXXXX
XXX.XX
XXXXXX
XX.X.X
XXXXXX
5
XXX.X
.X..X
XXX.X
..X..
..X..
| .X. XOX .X. XX.XXO XOXXOX OXX.XX XOOXXO XX.X.X OXXOXX XOX.X .X..X XXO.O ..X.. ..X.. | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*2100'] |
B. Balls of Steeltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n distinct points (x_1, y_1),\ldots,(x_n,y_n) on the plane and a non-negative integer parameter k. Each point is a microscopic steel ball and k is the attract power of a ball when it's charged.... | 3
3 2
0 0
3 3
1 1
3 3
6 7
8 8
6 9
4 1
0 0
0 1
0 2
0 3
| -1 1 -1 | 1 second | 256 megabytes | ['brute force', 'geometry', 'greedy', '*1000'] |
A. Avoid Trygubtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, "xy" is a subsequence of "xzyw" and "xy", but not "yx".You are... | 3
11
antontrygub
15
bestcoordinator
19
trywatchinggurabruh
| bugyrtnotna bestcoordinator bruhtrywatchinggura | 1 second | 256 megabytes | ['constructive algorithms', 'sortings', '*800'] |
B. Numbers Boxtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular grid with n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{ij} written in it.You can perform the following op... | 2
2 2
-1 1
1 1
3 4
0 -1 -2 -3
-1 -2 -3 -4
-2 -3 -4 -5
| 2 30 | 1 second | 256 megabytes | ['greedy', 'math', '*1000'] |
A. Add Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n bags with candies, initially the i-th bag contains i candies. You want all the bags to contain an equal amount of candies in the end. To achieve this, you will: Choose m such that 1 \le m \le 1... | 2
2
3
| 1 2 5 3 3 3 1 2 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Line Distancetime limit per test7.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer k and n distinct points with integer coordinates on the Euclidean plane, the i-th point has coordinates (x_i, y_i).Consider a list of all the \frac{n(n - 1)}{2} pairs of point... | 4 3
2 1
-2 -1
0 -1
-2 4
| 0.707106780737 | 7.5 seconds | 256 megabytes | ['binary search', 'data structures', 'geometry', '*3200'] |
E. Long Recoverytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA patient has been infected with an unknown disease. His body can be seen as an infinite grid of triangular cells which looks as follows: Two cells are neighboring if they share a side. Therefore, each... | 4
0 0
1 0
2 0
0 1
| RECOVERED 4 | 3 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', '*3500'] |
D2. Frequency Problem (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are s... | 7
1 1 2 2 3 3 3
| 6 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'two pointers', '*3000'] |
D1. Frequency Problem (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are s... | 7
1 1 2 2 3 3 3
| 6 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*2600'] |
C. Xor Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor a given sequence of distinct non-negative integers (b_1, b_2, \dots, b_k) we determine if it is good in the following way: Consider a graph on k nodes, with numbers from b_1 to b_k written on them. For ... | 5
0 1 5 2 6
| 1 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'data structures', 'divide and conquer', 'dp', 'trees', '*2100'] |
B. Catching Cheaterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4\cdot LCS(C,D) - |C| - |D|, wher... | 4 5
abba
babab
| 5 | 1 second | 256 megabytes | ['dp', 'strings', '*1800'] |
A. Knapsacktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a knapsack with the capacity of W. There are also n items, the i-th one has weight w_i. You want to put some of these items into the knapsack in such a way that their total weight C is at least half... | 3
1 3
3
6 2
19 8 19 69 9 4
7 12
1 1 1 17 1 1 1
| 1 1 -1 6 1 2 3 5 6 7 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1300'] |
B. Eliminationtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is a famous olympiad, which has more than a hundred participants. The Olympiad consists of two stages: the elimination stage, and the final stage. At least a hundred participants will advance to the ... | 2
1 2 2 1
4 8 9 2
| 3 12 | 1 second | 512 megabytes | ['greedy', 'math', '*900'] |
A. Array Rearrangmenttime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b, each consisting of n positive integers, and an integer x. Please determine if one can rearrange the elements of b so that a_i + b_i \leq x holds for each i (1 \le i... | 4
3 4
1 2 3
1 1 2
2 6
1 4
2 5
4 4
1 2 3 4
1 2 3 4
1 5
5
5
| Yes Yes No No | 1 second | 512 megabytes | ['greedy', 'sortings', '*800'] |
E. Finding the Vertextime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.You are given a tree — connected undirected graph without cycles. One vertex of the tree is special, and you have to find which one. You can ask questions in the follo... | 5
1 2
2 3
3 4
4 5
3
2
1
| ? 3 4 ? 2 3 ? 1 2 ! 1 | 1 second | 512 megabytes | ['brute force', 'dfs and similar', 'dp', 'interactive', 'trees', '*3500'] |
D. Rectangular Polylinetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOne drew a closed polyline on a plane, that consisted only of vertical and horizontal segments (parallel to the coordinate axes). The segments alternated between horizontal and vertical ones (a h... | 2
2
1 1
2
1 1
2
1 2
2
3 3
| Yes 1 0 1 1 0 1 0 0 No | 2 seconds | 512 megabytes | ['constructive algorithms', 'dp', 'geometry', '*2900'] |
C. Team-Buildingtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe new academic year has started, and Berland's university has n first-year students. They are divided into k academic groups, however, some of the groups might be empty. Among the students, there are ... | 6 8 3
1 1 2 2 3 3
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
| 2 | 3 seconds | 512 megabytes | ['data structures', 'dfs and similar', 'dsu', 'graphs', '*2500'] |
B. Divide and Sumtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a of length 2n. Consider a partition of array a into two subsequences p and q of length n each (each element of array a should be in exactly one subsequence: either in p or in q)... | 1
1 4
| 6 | 2 seconds | 512 megabytes | ['combinatorics', 'math', 'sortings', '*1900'] |
A. Divisiontime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputOleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.To improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to... | 3
10 4
12 6
179 822
| 10 4 179 | 1 second | 512 megabytes | ['brute force', 'math', 'number theory', '*1500'] |
E. Long Permutationtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] — are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] ... | 4 4
1 2 4
2 3
1 1 2
1 3 4
| 9 4 6 | 4 seconds | 256 megabytes | ['brute force', 'math', 'two pointers', '*2400'] |
C. The Delivery Dilemmatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya is preparing for his birthday. He decided that there would be n different dishes on the dinner table, numbered from 1 to n. Since Petya doesn't like to cook, he wants to order these dishes ... | 4
4
3 7 4 5
2 1 2 4
4
1 2 3 4
3 3 3 3
2
1 2
10 10
2
10 10
1 2
| 5 3 2 3 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'sortings', '*1400'] |
B. Saving the Citytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBertown is a city with n buildings in a straight line.The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character... | 2
1 1
01000010
5 1
01101110
| 2 6 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'math', 'sortings', '*1300'] |
A. Kids Seatingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday the kindergarten has a new group of n kids who need to be seated at the dinner table. The chairs at the table are numbered from 1 to 4n. Two kids can't sit on the same chair. It is known that two k... | 3
2
3
4
| 6 4 4 6 10 14 10 12 8 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Differentiating Gamestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problemGinny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a stan... | 3 2 3
1 2
2 3
Lose
Correct
Win
Correct
Draw
Correct | 6 + 2 2 - 1 2 + 2 3 - 2 2 + 3 1 + 2 2 ? 0 ! 1 ? 1 2 ! 3 ? 5 1 3 1 3 1 ! 2 | 2 seconds | 512 megabytes | ['games', 'interactive', '*3400'] |
E. Black, White and Grey Treetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree with each vertex coloured white, black or grey. You can remove elements from the tree by selecting a subset of vertices in a single connected component and removing the... | 4
2
1 1
1 2
4
1 2 1 2
1 2
2 3
3 4
5
1 1 0 1 2
1 2
2 3
3 4
3 5
8
1 2 1 2 2 2 1 2
1 3
2 3
3 4
4 5
5 6
5 7
5 8
| 1 3 2 3 | 2 seconds | 512 megabytes | ['binary search', 'constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'trees', '*3000'] |
D. Sumtime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given n non-decreasing arrays of non-negative numbers. Vasya repeats the following operation k times: Selects a non-empty array. Puts the first element of the selected array in his pocket. Removes t... | 3 3
2 5 10
3 1 2 3
2 1 20
| 26 | 1.5 seconds | 512 megabytes | ['data structures', 'divide and conquer', 'dp', 'greedy', '*2800'] |
C. Graph Transpositionstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1.The following actions are allowed: Token movement. To move the token fr... | 4 4
1 2
2 3
3 4
4 1
| 2 | 3 seconds | 512 megabytes | ['dfs and similar', 'graphs', 'greedy', 'shortest paths', '*2400'] |
B. Identify the Operationstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe start with a permutation a_1, a_2, \ldots, a_n and with an empty array b. We apply the following operation k times.On the i-th iteration, we select an index t_i (1 \le t_i \le n-i+1), remov... | 3
5 3
1 2 3 4 5
3 2 5
4 3
4 3 2 1
4 3 1
7 4
1 4 7 3 6 2 5
3 2 4 5
| 2 0 4 | 2 seconds | 512 megabytes | ['combinatorics', 'data structures', 'dsu', 'greedy', 'implementation', '*1800'] |
A. Extreme Subtractiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers.You can use the following operation as many times as you like: select any integer 1 \le k \le n and do one of two things: decrement by one k of th... | 4
3
1 2 1
5
11 7 9 6 8
5
1 3 1 3 1
4
5 2 1 10
| YES YES NO YES | 2 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', '*1800'] |
B. Sum of Medianstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA median of an array of integers of length n is the number standing on the \lceil {\frac{n}{2}} \rceil (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered start... | 6
2 4
0 24 34 58 62 64 69 78
2 2
27 61 81 91
4 3
2 4 16 18 21 27 36 53 82 91 92 95
3 4
3 11 12 22 33 35 38 67 69 71 94 99
2 1
11 41
3 3
1 1 1 1 1 1 1 1 1
| 165 108 145 234 11 3 | 1 second | 256 megabytes | ['greedy', 'math', '*900'] |
A. Buy the Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four integers n, c_0, c_1 and h and a binary string s of length n.A binary string is a string consisting of characters 0 and 1.You can change any character of the string s (the string shou... | 6
3 1 1 1
100
5 10 100 1
01010
5 10 1 1
11111
5 1 10 1
11111
12 2 1 10
101110110101
2 100 1 10
00
| 3 52 5 10 16 22 | 1 second | 256 megabytes | ['implementation', 'math', '*800'] |
E. Cheat and Wintime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider a (10^9+1) \times (10^9+1) field. The rows are numbered with integers from 0 to 10^9 and the columns are numbered with integers from 0 to 10^9. Let's define as (x, y) the cell located in ... | 1
7 0 0 7
| 1 | 3 seconds | 256 megabytes | ['bitmasks', 'data structures', 'games', 'trees', '*3500'] |
D. INOI Final Conteststime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday is the final contest of INOI (Iranian National Olympiad in Informatics). The contest room is a row with n computers. All computers are numbered with integers from 1 to n from left to right. ... | 3 1 1000000007
| 0 | 3 seconds | 256 megabytes | ['combinatorics', 'dp', 'fft', '*3100'] |
C. Greedy Shoppingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n of integers. This array is non-increasing.Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost... | 10 6
10 10 10 6 6 5 5 5 3 1
2 3 50
2 4 10
1 3 10
2 2 36
1 4 7
2 2 17
| 8 3 6 2 | 3 seconds | 256 megabytes | ['binary search', 'data structures', 'divide and conquer', 'greedy', 'implementation', '*2600'] |
B. Graph Subset Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph with n vertices and m edges. Also, you are given an integer k.Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subse... | 3
5 9 4
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
10 15 3
1 2
2 3
3 4
4 5
5 1
1 7
2 8
3 9
4 10
5 6
7 10
10 8
8 6
6 9
9 7
4 5 4
1 2
2 3
3 4
4 1
1 3
| 2 4 1 2 3 1 10 1 2 3 4 5 6 7 8 9 10 -1 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'graphs', '*2600'] |
A2. Binary Table (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both ver... | 5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
| 1 1 1 2 1 2 2 2 2 1 3 1 3 2 1 2 1 3 2 3 4 1 1 1 2 2 2 1 3 1 4 2 3 3 2 4 1 4 2 3 3 4 3 4 4 4 1 2 2 1 2 2 1 4 1 5 2 5 4 1 4 2 5 1 4 4 4 5 3 4 2 1 3 2 2 2 3 1 2 2 1 2 2 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'implementation', '*1900'] |
A1. Binary Table (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both ver... | 5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
| 1 1 1 2 1 2 2 2 2 1 3 1 3 2 1 2 1 3 2 3 4 1 1 1 2 2 2 1 3 1 4 2 3 3 2 4 1 4 2 3 3 4 3 4 4 4 1 2 2 1 2 2 1 4 1 5 2 5 4 1 4 2 5 1 4 4 4 5 3 4 2 1 3 2 2 2 3 1 2 2 1 2 2 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*1500'] |
F. Olha and Igortime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Igor wants to find the key to Olha's heart. The problem is, that it's at the root of a binary tree.There is a perfect binary tree of height h consisting of n = 2^{h} - 1 n... | 3
2
7
4 | ? 7 3 5 ? 1 6 4 ? 1 5 4 ! 4 | 4 seconds | 256 megabytes | ['interactive', 'probabilities', 'trees', '*3000'] |
E. Yurii Can Do Everythingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYurii is sure he can do everything. Can he solve this task, though?He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simul... | 8
3 1 2 3 1 2 3 15
| 6 | 1 second | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'constructive algorithms', 'divide and conquer', 'two pointers', '*2500'] |
D. Powerful Kseniatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKsenia has an array a consisting of n positive integers a_1, a_2, \ldots, a_n. In one operation she can do the following: choose three distinct indices i, j, k, and then change all of a_i, a_j, a_k ... | 5
4 2 1 7 2
| YES 1 1 3 4 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'math', '*2200'] |
C. Engineer Artemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputArtem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{i,j} written in it. If... | 3
3 2
1 2
4 5
7 8
2 2
1 1
3 3
2 2
1 3
2 2
| 1 2 5 6 7 8 2 1 4 3 2 4 3 2 | 1 second | 256 megabytes | ['2-sat', 'chinese remainder theorem', 'constructive algorithms', 'fft', 'flows', '*2000'] |
B. Valerii Against Everyonetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given an array b of length n. Let's define another array a, also of length n, for which a_i = 2^{b_i} (1 \leq i \leq n). Valerii says that every two non-intersecting subarrays of a have... | 2
6
4 3 0 1 2 0
2
2 5
| YES NO | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'sortings', '*1000'] |
A. Specific Tastes of Andre time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndre has very specific tastes. Recently he started falling in love with arrays.Andre calls an nonempty array b good, if sum of its elements is divisible by the length of this array. For exam... | 3
1
2
4
| 24 19 33 7 37 79 49 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
G. Death DBMStime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor the simplicity, let's say that the "Death Note" is a notebook that kills a person when their name is written in it.It's easy to kill with it, but it's pretty hard to keep track of people you haven't ki... | 5 8
kurou
takuo
takeshi
naomi
shingo
2 nakiraomi
2 abanaomicaba
1 3 943
2 takuotakeshishingo
1 5 135832
2 shingotakeshi
1 5 0
2 shingotakeshi
| -1 0 943 135832 943 | 2 seconds | 512 megabytes | ['data structures', 'string suffix structures', 'strings', 'trees', '*2600'] |
F. Emotional Fishermentime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputn fishermen have just returned from a fishing vacation. The i-th fisherman has caught a fish of weight a_i.Fishermen are going to show off the fish they caught to each other. To do so, they first... | 4
1 1 4 9
| 20 | 4 seconds | 1024 megabytes | ['combinatorics', 'dp', 'math', 'two pointers', '*2600'] |
E. Make It Increasingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n integers a_1, a_2, ..., a_n, and a set b of k distinct integers from 1 to n.In one operation, you may choose two integers i and x (1 \le i \le n, x can be any integer) a... | 7 2
1 2 1 1 3 5 1
3 5
| 4 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'dp', 'implementation', '*2200'] |
D. Minimal Height Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp had a tree which consisted of n vertices and was rooted at vertex 1. He decided to study BFS (Breadth-first search), so he ran BFS on his tree, starting from the root. BFS can be describe... | 3
4
1 4 3 2
2
1 2
3
1 2 3
| 3 1 1 | 2 seconds | 256 megabytes | ['graphs', 'greedy', 'shortest paths', 'trees', '*1600'] |
C. Chef Monocarptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputChef Monocarp has just put n dishes into an oven. He knows that the i-th dish has its optimal cooking time equal to t_i minutes.At any positive integer minute T Monocarp can put no more than one dish ou... | 6
6
4 2 4 4 5 2
7
7 7 7 7 7 7 7
1
1
5
5 1 2 4 3
4
1 4 4 4
21
21 8 1 4 1 5 21 1 8 21 11 21 11 3 12 8 19 15 9 11 13
| 4 12 0 0 2 21 | 2 seconds | 256 megabytes | ['dp', 'flows', 'graph matchings', 'greedy', 'math', 'sortings', '*1800'] |
B. Reverse Binary Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of even length n. String s is binary, in other words, consists only of 0's and 1's.String s has exactly \frac{n}{2} zeroes and \frac{n}{2} ones (n is even).In one opera... | 3
2
10
4
0110
8
11101000
| 0 1 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*1200'] |
A. Marketing Schemetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou got a job as a marketer in a pet shop, and your current task is to boost sales of cat food. One of the strategies is to sell cans of food in packs with discounts. Suppose you decided to sell packs... | 3
3 4
1 2
120 150
| YES NO YES | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', '*800'] |
F. Sum Over Subsetstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a multiset S. Over all pairs of subsets A and B, such that: B \subset A; |B| = |A| - 1; greatest common divisor of all elements in A is equal to one; find the sum of \sum_{x \in A}{x}... | 2
1 1
2 1
| 9 | 1 second | 256 megabytes | ['combinatorics', 'math', 'number theory', '*2800'] |
E. Complicated Computationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn this problem MEX of a certain array is the smallest positive integer not contained in this array.Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a ... | 3
1 3 2
| 3 | 1 second | 256 megabytes | ['binary search', 'data structures', 'two pointers', '*2400'] |
D. Bandit in a Citytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBandits appeared in the city! One of them is trying to catch as many citizens as he can.The city consists of n squares connected by n-1 roads in such a way that it is possible to reach any square from... | 3
1 1
3 1 2
| 3 | 1 second | 256 megabytes | ['binary search', 'dfs and similar', 'graphs', 'greedy', 'trees', '*1900'] |
C. Binary Searchtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allow... | 4 1 2
| 6 | 1 second | 256 megabytes | ['binary search', 'combinatorics', '*1500'] |
B. Prime Squaretime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha likes investigating different math objects, for example, magic squares. But Sasha understands that magic squares have already been studied by hundreds of people, so he sees no sense of studying t... | 2
4
2
| 4 6 8 1 4 9 9 9 4 10 10 65 1 4 4 4 1 1 1 1 | 1.5 seconds | 256 megabytes | ['constructive algorithms', 'math', '*900'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.