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 |
|---|---|---|---|---|---|
H. Submatricestime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given matrix s that contains n rows and m columns. Each element of a matrix is one of the 5 first Latin letters (in upper case).For each k (1 \le k \le 5) calculate the number of submatrices tha... | 2 3
ABB
ABA
| 9 9 0 0 0 | 3.5 seconds | 256 megabytes | ['*special problem', 'bitmasks', 'data structures', 'dp'] |
G. Biome Maptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp decided to generate a biome map for his game. A map is a matrix divided into cells 1 \times 1. Each cell of the map must contain one of the available biomes.Each biome is defined by two parameters:... | 4
2 3
0 2 5
0 1 0
3 5
0 3 4 9 11
1 5 0 10 12
0 6 7 0 0
2 2
2 0
0 5
1 2
13 37
| 1 3 5 2 1 2 8 11 9 4 3 5 1 5 6 12 10 9 4 3 5 6 7 -1 1 2 13 37 | 2 seconds | 256 megabytes | ['*special problem', 'constructive algorithms', 'dfs and similar', 'graphs'] |
F. Binary String Partitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a string t consisting of characters 0 and/or 1 beautiful, if either the number of occurrences of character 0 in this string does not exceed k, or the number of occurrences of charac... | 00100010
| 2 1 1 1 1 1 1 1 | 2 seconds | 256 megabytes | ['*special problem', 'binary search', 'greedy'] |
E. Chess Team Formingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is coaching a team for an upcoming game at the chess tournament. A complete team for the tournament should consist of n+1 members.There are n members in his team, the i-th member's skill v... | 5
10 3 4 6 1
9 4 2 5 9 8
5
1 7 6 4 8
| 4 2 3 4 2 | 2 seconds | 256 megabytes | ['*special problem', 'binary search', 'data structures', 'greedy'] |
D. String Searchingtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array s consisting of n different strings. Each string consists of m lowercase Latin letters.You have to respond to q queries. Each query contains a string t of length m+1. Count the... | 2 1
a
c
4
aa
ca
mm
cf
| 1 2 0 1 | 3 seconds | 256 megabytes | ['*special problem', 'hashing'] |
C. Sweetstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnya came to her friend's birthday party. There are n delicious sweets on a circle table (for convenience, we will number them from 1 to n in clockwise direction). For each of the sweets, it is known whether A... | 4
6 4
000111
7 3
0000100
3 2
000
5 1
10011
| 4 4 0 5 | 3 seconds | 256 megabytes | ['*special problem', 'data structures', 'implementation'] |
B. Nearest Point Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend has created a nearest point function. For a given array of integer points x (sorted in ascending order, without any duplicates) and a point y it can find the nearest point from x to ... | 7
2
1 3
2
1 100
3
1 50 101
2
1 1000000000
2
1 999999999
6
1 2 5 7 9 11
6
1 2 5 8 9 12
| YES NO NO NO YES YES NO | 1 second | 256 megabytes | ['*special problem', 'implementation'] |
A. Travel to Bertowntime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVika has decided to go on a trip to Bertown. She comes to Bertown on the k-th day. Vika does not want to spend money on hotels, fortunately she has n friends who live in Bertown and allow Vika to st... | 3
3 3
1 4
2 6
4 10
2 4
2 3
5 8
2 4
4 4
1 3
| 4 0 1 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', 'math'] |
F. Prefixes and Suffixestime limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputIvan wants to play a game with you. He picked some string s of length n consisting only of lowercase Latin letters. You don't know this string. Ivan has informed you about all its improper prefixes and suf... | 5
ba
a
abab
a
aba
baba
ab
aba
| SPPSPSPS | 2.0 s | 512 MB | ['*special problem', 'strings'] |
E. Good Arraytime limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputLet's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array a=[1, 3, 3, 7] is good because there is the element a_4=7 which equals to the sum 1 + ... | 5
2 5 1 2 2
| 3 4 1 5 | 2.0 s | 512 MB | ['*special problem'] |
D. Teams Formingtime limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputThere are n students in a university. The number of students is even. The i-th student has programming skill equal to a_i. The coach wants to form \frac{n}{2} teams. Each team should consist of exactly two student... | 6
5 10 2 3 14 5
| 5 | 2.0 s | 512 MB | ['*special problem', 'sortings'] |
C. Uniform Stringtime limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputYou are given two integers n and k.Your task is to construct such a string s of length n that for each i from 1 to k there is at least one i-th letter of the Latin alphabet in this string (the first letter is 'a'... | 3
7 3
4 4
6 2
| cbcacab abcd baabab | 2.0 s | 512 MB | ['*special problem', 'implementation'] |
B. Frog Jumpingtime limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputA frog is currently at the point 0 on a coordinate axis Ox. It jumps by the following algorithm: the first jump is a units to the right, the second jump is b units to the left, the third jump is a units to the righ... | 6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999
| 8 198 -17 2999999997 0 1 | 2.0 s | 512 MB | ['*special problem', 'math'] |
A. A+B (Trial Problem)time limit per test2.0 smemory limit per test512 MBinputstandard inputoutputstandard outputYou are given two integers a and b. Print a+b.InputThe first line contains an integer t (1 \le t \le 10^4) — the number of test cases in the input. Then t test cases follow.Each test case is given as a line ... | 41 5314 15-99 99123 987 | 6 329 0 1110 | 2.0 s | 512 MB | ['*special problem'] |
E3. Сортировка слияниемограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводРассмотрим следующий код сортировки слиянием на языке Python: def sort(a): n = len(a) b = [0 for i in range(n)] log = [] def mergeSort(l, r): if r - l <= 1: return... | Входные данные
00000000000000000000000000000000
| Выходные данные 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', 'binary search'] |
E2. Сортировка слияниемограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводРассмотрим следующий код сортировки слиянием на языке Python: def sort(a): n = len(a) b = [0 for i in range(n)] log = [] def mergeSort(l, r): if r - l <= 1: return... | Входные данные
00000000000000000000000000000000
| Выходные данные 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', '*special problem', 'brute force'] |
E1. Сортировка слияниемограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводРассмотрим следующий код сортировки слиянием на языке Python: def sort(a): n = len(a) b = [0 for i in range(n)] log = [] def mergeSort(l, r): if r - l <= 1: return... | Входные данные
00000000000000000000000000000000
| Выходные данные 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem'] |
D. Редактируем Зингер | colorограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводНемногие знают, что сотрудники ВКонтакте могут менять цвет подсветки в куполе знаменитого Дома Зингера, где расположена штаб-квартира ВКонтакте. Для этого нужно всего ли... | Входные данные
7
red
violet
unlock
red
orange
lock
indigo
6
5 green
6 lock
6 yellow
4 lock
1 lock
5 unlock
| Выходные данные orange green green indigo violet blue indigo | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', '*special problem'] |
C. Симметричный амфитеатрограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводВсе готовятся к VK Fest 2021! Для того, чтобы зрителям была лучше видна главная сцена, планируется построить амфитеатр. В этой задаче мы будем рассматривать его сбоку — схем... | Входные данные
3
| Выходные данные 2 o. oo | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', 'constructive algorithms', 'dp'] |
B2. Мониторингограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводВКонтакте открыла второй штаб в Санкт-Петербурге! Вы не преминули возможностью сменить обстановку и решили переехать из офиса в Доме Зингера в офис на Красном мосту.Для комфортной рабо... | Входные данные
5
3 2
2 2
5 5
3 5
4 3
| Выходные данные 5 | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem'] |
B1. Мониторингограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводВКонтакте открыла второй штаб в Санкт-Петербурге! Вы не преминули возможностью сменить обстановку и решили переехать из офиса в Доме Зингера в офис на Красном мосту.Для комфортной рабо... | Входные данные
5
3 2
2 2
5 5
3 5
4 3
| Выходные данные 5 | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', '*special problem'] |
A. Зингер | colorограничение по времени на тест2 секундыограничение по памяти на тест512 мегабайтвводстандартный вводвыводстандартный выводНемногие знают, что сотрудники ВКонтакте могут менять цвет подсветки в куполе знаменитого Дома Зингера, где расположена штаб-квартира ВКонтакте. Для этого нужно всего лишь отправить... | Входные данные
7
red
violet
unlock
red
orange
lock
indigo
| Выходные данные orange | ограничение по времени на тест2 секунды | ограничение по памяти на тест512 мегабайт | ['*special problem', 'implementation'] |
H. Turing's Awardtime limit per test10 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlan Turing is standing on a tape divided into cells that is infinite in both directions.Cells are numbered with consecutive integers from left to right. Alan is initially standing in cell 0. Every ce... | 4
2
1 2
4
4 1 2 3
7
3 6 5 7 4 1 2
7
5 2 3 7 6 1 4
| 2 3 4 4 | 10 seconds | 512 megabytes | ['data structures', 'dp', '*3400'] |
G. What a Reversaltime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have two strings a and b of equal length n consisting of characters 0 and 1, and an integer k.You need to make strings a and b equal.In one step, you can choose any substring of a containing exact... | 6
6 1
101010
010101
6 3
101010
010101
6 0
101010
010101
6 6
101010
010101
4 2
0000
1111
9 2
011100101
101001011
| 3 1 2 3 4 5 6 1 1 6 -1 -1 -1 5 4 8 8 9 3 6 1 4 3 6 | 2 seconds | 512 megabytes | ['constructive algorithms', '*3300'] |
F. Bingotime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGetting ready for VK Fest 2021, you prepared a table with n rows and n columns, and filled each cell of this table with some event related with the festival that could either happen or not: for example, whether... | 2
5000 5000
5000 5000
| 5927 | 7 seconds | 512 megabytes | ['bitmasks', 'combinatorics', 'dp', 'math', 'probabilities', '*2600'] |
E. Minimaxtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPrefix function of string t = t_1 t_2 \ldots t_n and position i in it is defined as the length k of the longest proper (not equal to the whole substring) prefix of substring t_1 t_2 \ldots t_i which is also a... | 3
vkcup
abababa
zzzzzz
| ckpuv aababab zzzzzz | 2 seconds | 512 megabytes | ['constructive algorithms', 'greedy', 'strings', '*2100'] |
D. Secret Santatime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputEvery December, VK traditionally holds an event for its employees named "Secret Santa". Here's how it happens.n employees numbered from 1 to n take part in the event. Each employee i is assigned a differ... | 2
3
2 1 2
7
6 4 6 2 4 5 6
| 2 3 1 2 4 6 4 7 2 3 5 1 | 2 seconds | 512 megabytes | ['constructive algorithms', 'flows', 'graphs', 'greedy', 'math', '*1600'] |
C. Pursuittime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou and your friend Ilya are participating in an individual programming contest consisting of multiple stages. A contestant can get between 0 and 100 points, inclusive, for each stage, independently of other ... | 5
1
100
0
1
0
100
4
20 30 40 50
100 100 100 100
4
10 20 30 40
100 100 100 100
7
7 59 62 52 27 31 55
33 35 50 98 83 80 64
| 0 1 3 4 2 | 2 seconds | 512 megabytes | ['binary search', 'brute force', 'greedy', 'sortings', '*1200'] |
B. Putting Platestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTo celebrate your birthday you have prepared a festive table! Now you want to seat as many guests as possible.The table can be represented as a rectangle with height h and width w, divided into h \time... | 3
3 5
4 4
5 6
| 10101 00000 10101 0100 0001 1000 0010 010101 000000 100001 000000 101010 | 2 seconds | 512 megabytes | ['constructive algorithms', 'implementation', '*800'] |
A. Binary Decimaltime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's call a number a binary decimal if it's a positive integer and all digits in its decimal notation are either 0 or 1. For example, 1\,010\,111 is a binary decimal, while 10\,201 and 787\,788 are not... | 3
121
5
1000000000
| 2 5 1 | 1 second | 512 megabytes | ['greedy', 'math', '*800'] |
B. Sifid and Strange Subsequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence (b_1, b_2, \ldots, b_k) is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formall... | 6
4
-1 -2 0 0
7
-3 4 -2 0 -4 6 1
5
0 5 -3 2 -5
3
2 3 1
4
-3 0 2 0
6
-3 -2 -1 1 1 1
| 4 5 4 1 3 4 | 1 second | 256 megabytes | ['greedy', 'math', 'sortings', '*1100'] |
A. Eshag Loves Big Arraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEshag has an array a consisting of n integers.Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly large... | 3
6
1 1 1 2 2 3
6
9 9 9 9 9 9
6
6 4 1 1 4 1
| 3 0 3 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*800'] |
F. AmShZ Farmtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo AmShZ, all arrays are equal, but some arrays are more-equal than others. Specifically, the arrays consisting of n elements from 1 to n that can be turned into permutations of numbers from 1 to n by addi... | 1 1
| 1 | 2 seconds | 256 megabytes | ['combinatorics', 'fft', 'math', '*3300'] |
E. Mashtali and Hagh Treestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday is Mashtali's birthday! He received a Hagh tree from Haj Davood as his birthday present!A directed tree is called a Hagh tree iff: The length of the longest directed path in it is exact... | 1
| 5 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'trees', '*2900'] |
D. It's a bird! No, it's a plane! No, it's AaParsa!time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities in Shaazzzland, numbered from 0 to n-1. Ghaazzzland, the immortal enemy of Shaazzzland, is ruled by AaParsa.As the head of the Ghaazzzland's intelli... | 3 4
0 1 1
0 2 3
1 0 1
2 0 1
| 0 1 2 1 0 2 1 2 0 | 5 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'shortest paths', '*2500'] |
C. Trees of Tranquillitytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSoroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.Soroush and Keshi used to be at war. After endless decades of fighting, they fin... | 4
4
1 2 3
1 2 3
5
1 2 3 4
1 1 1 1
6
1 1 1 1 2
1 2 1 2 2
7
1 1 3 4 4 5
1 2 1 4 2 5
| 1 4 1 3 | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'greedy', 'trees', '*2300'] |
B. Kavi on Pairing Dutytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKavi has 2n points lying on the OX axis, i-th of which is located at x = i.Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are ... | 1
| 1 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'math', '*1700'] |
A. Parsa's Humongous Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputParsa has a humongous tree on n vertices.On each vertex v he has written two integers l_v and r_v.To make Parsa's tree look even more majestic, Nima wants to assign a number a_v (l_v \le a_v \le... | 3
2
1 6
3 8
1 2
3
1 3
4 6
7 9
1 2
2 3
6
3 14
12 20
12 19
2 12
10 17
3 17
3 2
6 5
1 5
2 6
4 6
| 7 8 62 | 1 second | 256 megabytes | ['dfs and similar', 'divide and conquer', 'dp', 'greedy', 'trees', '*1600'] |
E. Partition Gametime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. Define the cost of some array t as follows:cost(t) = \sum_{x \in set(t) } last(x) - first(x), where set(t) is the set of all values in t without repetitions, fir... | 7 2
1 6 6 4 6 6 6
| 3 | 3 seconds | 256 megabytes | ['binary search', 'data structures', 'divide and conquer', 'dp', '*2500'] |
D. MEX Treetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n nodes, numerated from 0 to n-1. For each k between 0 and n, inclusive, you have to count the number of unordered pairs (u,v), u \neq v, such that the MEX of all the node labels ... | 2
4
0 1
0 2
2 3
2
1 0
| 1 2 1 1 1 0 0 1 | 1.5 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'implementation', 'math', 'trees', '*2400'] |
C. Sequence Pair Weighttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe weight of a sequence is defined as the number of unordered pairs of indexes (i,j) (here i \lt j) with same value (a_{i} = a_{j}). For example, the weight of sequence a = [1, 1, 2, 2, 1] is 4.... | 2
4
1 2 1 1
4
1 2 3 4
| 6 0 | 2 seconds | 256 megabytes | ['hashing', 'implementation', 'math', '*1600'] |
B2. Palindrome Game (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is that the given string s in the easy version is initially a palindrome, this condition is not always true for the hard version.A... | 3
3
110
2
00
4
1010
| ALICE BOB ALICE | 1 second | 256 megabytes | ['constructive algorithms', 'games', '*1900'] |
B1. Palindrome Game (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions is that the given string s in the easy version is initially a palindrome, this condition is not always true for the hard version.A... | 2
4
1001
1
0
| BOB BOB | 1 second | 256 megabytes | ['constructive algorithms', 'games', '*1200'] |
A. And Then There Were Ktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an integer n, find the maximum value of integer k such that the following condition holds: n & (n-1) & (n-2) & (n-3) & ... (k) = 0 where & denotes the bitwise AND operation.InputThe first... | 3
2
5
17
| 1 3 15 | 1 second | 256 megabytes | ['bitmasks', '*800'] |
F. Median Queriestime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There is a secret permutation p (1-indexed) of numbers from 1 to n. More formally, for 1 \leq i \leq n, 1 \leq p[i] \leq n and for 1 \leq i < j \leq n, p[i] \neq p[j]. It... | 1
20
6
9
1 | ? 1 5 2 ? 20 19 2 ! 9 10 19 7 16 18 11 14 15 6 20 8 17 4 5 3 12 2 13 1 | 6 seconds | 256 megabytes | ['constructive algorithms', 'interactive', 'probabilities', '*3000'] |
E. Oolimry and Suffix Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array. More formally, given a suffix array of length n and having an alphabet size k, count t... | 3 2
0 2 1
| 1 | 1 second | 256 megabytes | ['combinatorics', 'constructive algorithms', 'math', '*2400'] |
D. Kill Antontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAfter rejecting 10^{100} data structure problems, Errorgorn is very angry at Anton and decided to kill him.Anton's DNA can be represented as a string a which only contains the characters "ANTON" (there are... | 4
ANTON
NAAN
AAAAAA
OAANTTON
| NNOTA AANN AAAAAA TNNTAOOA | 2 seconds | 512 megabytes | ['brute force', 'constructive algorithms', 'data structures', 'math', 'strings', '*2200'] |
C2. Potions (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version n \leq 200000. You can make hacks only if both versions of the problem are solved.There are n potions in a l... | 6
4 -4 1 -3 1 -3
| 5 | 1 second | 256 megabytes | ['data structures', 'greedy', '*1600'] |
C1. Potions (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version n \leq 2000. You can make hacks only if both versions of the problem are solved.There are n potions in a lin... | 6
4 -4 1 -3 1 -3
| 5 | 1 second | 256 megabytes | ['brute force', 'data structures', 'dp', 'greedy', '*1500'] |
B. I Hate 1111time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer x. Can you make x by summing up some number of 11, 111, 1111, 11111, \ldots? (You can use any number among them any number of times).For instance, 33=11+11+11 144=111+11+11+11 I... | 3
33
144
69
| YES YES NO | 1 second | 256 megabytes | ['dp', 'math', 'number theory', '*1400'] |
A. Mean Inequalitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of 2n distinct integers. You want to arrange the elements of the array in a circle such that no element is equal to the the arithmetic mean of its 2 neighbours.More formally, f... | 3
3
1 2 3 4 5 6
2
123 456 789 10
1
6 9
| 3 1 4 2 5 6 123 10 456 789 9 6 | 1 second | 256 megabytes | ['constructive algorithms', 'sortings', '*800'] |
F. Goblins And Gnomestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.The city consists of n halls and m one-... | 5 4 4
1 2
2 3
4 3
5 3
100 1
200 5
10 10
100 1
| 6 -2 -3 0 0 0 0 | 4 seconds | 512 megabytes | ['brute force', 'dp', 'flows', 'graph matchings', '*2800'] |
E. Assimilation IVtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.Monocarp's empire has n cities. In order to conquer new lands he plans to bui... | 3 5
1 4 4 3 4
1 4 1 4 2
1 4 4 4 3
| 166374062 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', 'probabilities', 'two pointers', '*2100'] |
D. Armchairstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than ... | 7
1 0 0 1 0 0 1
| 3 | 2 seconds | 512 megabytes | ['dp', 'flows', 'graph matchings', 'greedy', '*1800'] |
C. Robot Collisionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n robots driving along an OX axis. There are also two walls: one is at coordinate 0 and one is at coordinate m.The i-th robot starts at an integer coordinate x_i~(0 < x_i < m) and moves eit... | 5
7 12
1 2 3 4 9 10 11
R R L L R R R
2 10
1 6
R R
2 10
1 3
L L
1 10
5
R
7 8
6 1 7 2 3 5 4
R L R L L L L
| 1 1 1 1 2 -1 2 -1 -1 2 2 -1 -1 2 7 3 2 7 3 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', 'sortings', '*2000'] |
B. Permutation Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a consisting of n numbers 1, 2, ..., n (a permutation is an array in which each element from 1 to n occurs exactly once).You can perform the following operation: choose so... | 3
4
1 3 2 4
3
1 2 3
5
2 1 4 5 3
| 1 0 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*900'] |
A. Potion-makingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an initially empty cauldron, and you want to brew a potion in it. The potion consists of two ingredients: magic essence and water. The potion you want to brew should contain exactly k\ \% magic ... | 3
3
100
25
| 100 1 4 | 1 second | 256 megabytes | ['math', 'number theory', '*800'] |
H. Hopping Around the Array time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William really wants to get a pet. Since his childhood he dreamt about getting a pet grasshopper. William is being very responsible about choosing his pet, so he wants to set up a trial fo... | 9 5
1 1 2 1 3 1 2 1 1
1 1 0
2 5 1
5 9 1
2 8 2
1 9 4
| 0 2 1 2 2 | 2 seconds | 256 megabytes | ['data structures', 'dp', '*3500'] |
G. Try Bookingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output William owns a flat in central London. He decided to rent his flat out for the next n days to earn some money.Since his flat is in the center of the city, he instantly got m offers in the form (l_i, r_i... | 6 5
2 3
3 5
1 1
1 5
1 6
| 3 2 3 5 5 6 | 2 seconds | 512 megabytes | ['data structures', 'divide and conquer', '*3200'] |
F. Favorite Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output After William is done with work for the day, he enjoys playing his favorite video game.The game happens in a 2D world, starting at turn 0. William can pick any cell in the game world and spawn in it. ... | 3 4
1 1
2 3
5 2
2 2 12
5 1 4
6 2 11
3 5 10
| 3 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', '*3300'] |
E. Crypto Lightstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:Initially, all lights on William... | 3
3 2
15 2
40 15
| 333333338 141946947 329622137 | 3 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', 'probabilities', '*2600'] |
D. Love-Hatetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William is hosting a party for n of his trader friends. They started a discussion on various currencies they trade, but there's an issue: not all of his trader friends like every currency. They like some ... | 3 4 3
1000
0110
1001
| 1000 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'probabilities', '*2400'] |
C. Compression and Expansiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William is a huge fan of planning ahead. That is why he starts his morning routine by creating a nested list of upcoming errands.A valid nested list is any list which can be created from a... | 2
4
1
1
2
3
9
1
1
1
2
2
1
2
1
2
| 1 1.1 1.2 1.3 1 1.1 1.1.1 1.1.2 1.2 1.2.1 2 2.1 2.2 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'greedy', 'implementation', 'trees', '*1600'] |
B. Lord of the Valuestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output While trading on his favorite exchange trader William realized that he found a vulnerability. Using this vulnerability he could change the values of certain internal variables to his advantage. To... | 2
4
1 1 1 1
4
4 3 1 2
| 8 2 1 2 2 1 2 2 1 3 2 1 3 2 1 4 2 1 4 1 1 2 1 1 2 8 2 1 4 1 2 4 1 2 4 1 2 4 1 3 4 1 1 2 1 1 2 1 1 4 | 1 second | 256 megabytes | ['constructive algorithms', '*1100'] |
A. Game of Lifetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output William really likes the cellular automaton called "Game of Life" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing n cells, ... | 4
11 3
01000000001
10 2
0110100101
5 2
10101
3 100
000
| 11111001111 1110111101 10101 000 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Nastia and a Beautiful Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing?Let a_i be how many numbers i (1 \le i \le k) you have.An n \times n matri... | 2
3 4
2 0 0 1
15 4
2 4 8 1
| 2 4 1 0 1 5 3 0 0 2 2 3 2 3 3 0 0 1 0 4 0 3 0 0 0 0 2 1 3 3 3 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'dp', 'greedy', '*2700'] |
D. Nastia Plays with a Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNastia has an unweighted tree with n vertices and wants to play with it!The girl will perform the following operation with her tree, as long as she needs: Remove any existing edge. Add an e... | 2
7
1 2
1 3
2 4
2 5
3 6
3 7
4
1 2
1 3
3 4
| 2 2 5 6 7 3 6 4 5 0 | 3 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'dfs and similar', 'dp', 'dsu', 'greedy', 'implementation', 'trees', '*2500'] |
C. Nastia and a Hidden Permutationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem!Nastia has a hidden permutation p of length n consisting of integers from 1 to n. You, for some reason, want to figure out the permutation. To do that, y... | 2
4
3
2
5
3 | ? 2 4 1 3 ? 1 2 4 2 ! 3 1 4 2 ? 2 3 4 2 ! 2 5 3 4 1 | 3 seconds | 256 megabytes | ['constructive algorithms', 'interactive', '*2000'] |
B. Nastia and a Good Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNastia has received an array of n positive integers as a gift.She calls such an array a good that for all i (2 \le i \le n) takes place gcd(a_{i - 1}, a_{i}) = 1, where gcd(u, v) denotes the g... | 2
5
9 6 3 11 15
3
7 5 13
| 2 1 5 11 9 2 5 7 6 0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1300'] |
A. Nastia and Nearly Good Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNastia has 2 positive integers A and B. She defines that: The integer is good if it is divisible by A \cdot B; Otherwise, the integer is nearly good, if it is divisible by A. For examp... | 3
5 3
13 2
7 11
| YES 10 50 60 YES 169 39 208 YES 28 154 182 | 1 second | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1000'] |
G. To Go Or Not To Go?time limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDima overslept the alarm clock, which was supposed to raise him to school.Dima wonders if he will have time to come to the first lesson. To do this, he needs to know the minimum time it will take ... | 5 5 1
0 -1 0 1 -1
0 20 0 0 -1
-1 -1 -1 -1 -1
3 0 0 0 0
-1 0 0 0 0
| 14 | 3 seconds | 512 megabytes | ['brute force', 'dfs and similar', 'graphs', 'greedy', 'implementation', 'shortest paths', '*2200'] |
F2. Guess the K-th Zero (Hard version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.This is a hard version of the problem. The difference from the easy version is that in the hard version 1 \le t \le \min(n, 10^4) and the total numbe... | 6 2
2
2
1
1
0
1
0 | ? 4 6 ? 1 1 ? 1 2 ? 5 5 ! 5 ? 2 2 ! 2 | 4 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'interactive', '*2200'] |
F1. Guess the K-th Zero (Easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.This is an easy version of the problem. The difference from the hard version is that in the easy version t=1 and the number of queries is limited to 2... | 6 1
2
2
1
1
0
0 | ? 4 6 ? 1 1 ? 1 2 ? 2 2 ? 5 5 ! 5 | 1 second | 256 megabytes | ['binary search', 'interactive', '*1600'] |
E. Arranging The Sheeptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (em... | 5
6
**.*..
5
*****
3
.*.
3
...
10
*.*...*.**
| 1 0 0 0 9 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1400'] |
D. Same Differencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. Count the number of pairs of indices (i, j) such that i < j and a_j - a_i = j - i.InputThe first line contains one integer t (1 \le t \le 10^4). Then t test ca... | 4
6
3 5 1 4 6 6
3
1 2 3
4
1 3 3 4
6
1 6 3 4 5 6
| 1 3 3 10 | 2 seconds | 256 megabytes | ['data structures', 'hashing', 'math', '*1200'] |
C. Not Adjacent Matrixtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe will consider the numbers a and b as adjacent if they differ by exactly one, that is, |a-b|=1.We will consider cells of a square matrix n \times n as adjacent if they have a common side, that i... | 3
1
2
3
| 1 -1 2 9 7 4 6 3 1 8 5 | 4 seconds | 256 megabytes | ['constructive algorithms', '*1000'] |
B. Ordinary Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a positive integer n ordinary if in the decimal notation all its digits are the same. For example, 1, 2 and 99 are ordinary numbers, but 719 and 2021 are not ordinary numbers.For a given n... | 6
1
2
3
4
5
100
| 1 2 3 4 5 18 | 2 seconds | 256 megabytes | ['brute force', 'math', 'number theory', '*800'] |
A. Do Not Be Distracted!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has 26 tasks. Each task is designated by a capital letter of the Latin alphabet.The teacher asked Polycarp to solve tasks in the following way: if Polycarp began to solve some task, then... | 5
3
ABA
11
DDBBCCCBBEZ
7
FFGZZZY
1
Z
2
AB
| NO NO YES YES YES | 1 second | 256 megabytes | ['brute force', 'implementation', '*800'] |
F. Chests and Keystime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob play a game. Alice has got n treasure chests (the i-th of which contains a_i coins) and m keys (the j-th of which she can sell Bob for b_j coins).Firstly, Alice puts some locks on the ch... | 2 3
3 3
1 1 4
10 20 100
20 15 80
| 205 | 3 seconds | 512 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'dp', 'flows', '*3200'] |
E. Off by Onetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer.In one move you perform the following operation... | 7
4 1 5 1
1 1 1 1
3 3 3 3
1 1 4 1
6 1 1 1
5 1 4 1
6 1 1 1
| 3 1 6 2 4 5 7 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'geometry', 'graphs', 'sortings', 'trees', '*2700'] |
D. Maximum Sum of Productstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integer arrays a and b of length n.You can reverse at most one subarray (continuous subsegment) of the array a. Your task is to reverse such a subarray that the sum \sum\limi... | 5
2 3 2 1 3
1 3 2 4 2
| 29 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'implementation', 'math', 'two pointers', '*1600'] |
C. Berland Regionaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is an organizer of a Berland ICPC regional event. There are n universities in Berland numbered from 1 to n. Polycarp knows all competitive programmers in the region. There are n students: th... | 4
7
1 2 1 2 1 2 1
6 8 3 1 5 1 5
10
1 1 1 2 2 2 2 3 3 3
3435 3014 2241 2233 2893 2102 2286 2175 1961 2567
6
3 3 3 3 3 3
5 9 6 7 9 7
1
1
3083
| 29 28 26 19 0 0 0 24907 20705 22805 9514 0 0 0 0 0 0 43 43 43 32 38 43 3083 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'greedy', 'number theory', 'sortings', '*1400'] |
B. The Cake Is a Lietime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a n \times m grid. You are standing at cell (1, 1) and your goal is to finish at cell (n, m).You can move to the neighboring cells to the right or down. In other words, suppose you are stan... | 6
1 1 0
2 2 2
2 2 3
2 2 4
1 4 3
100 100 10000
| YES NO YES NO YES NO | 2 seconds | 256 megabytes | ['dp', 'math', '*800'] |
A. Red and Blue Beanstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have r red and b blue beans. You'd like to distribute them among several (maybe, one) packets in such a way that each packet: has at least one red bean (or the number of red beans r_i \ge 1); ... | 4
1 1 0
2 7 3
6 1 4
5 4 0
| YES YES NO NO | 1 second | 256 megabytes | ['math', '*800'] |
H. Fly Around the Worldtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter hearing the story of Dr. Zhang, Wowo decides to plan his own flight around the world. He already chose n checkpoints in the world map. Due to the landform and the clouds, he cannot fly too ... | 4
3
0 1
0 1
0 1
1 1
1 1
-100 100
3
-967 541
-500 834
-724 669
-858 978
-964 962
-645 705
4
0 0
0 1
0 1
1 1
0 1
0 1
0 1
0 0
0 0
4
0 0
33 34
65 66
100 100
0 100
0 100
0 100
0 0
0 0
| NO YES YES NO | 5 seconds | 256 megabytes | ['dp', 'geometry', '*3500'] |
G. Starry Night Campingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAt the foot of Liyushan Mountain, n tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, ... | 5
0 0 4
0 1 5
1 0 3
1 1 1
-1 1 2
| 12 | 2 seconds | 256 megabytes | ['constructive algorithms', 'flows', 'graphs', '*3300'] |
F. Reuniontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is reported that the 2050 Conference will be held in Yunqi Town in Hangzhou from April 23 to 25, including theme forums, morning jogging, camping and so on.The relationship between the n volunteers of the ... | 3
1 2
2 3
| 499122177 | 3 seconds | 256 megabytes | ['combinatorics', 'dp', 'trees', '*3200'] |
E. Group Phototime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each ... | 3
5
2 1 2 1 1
4
9 2 2 2
1
998244353
| 10 7 1 | 1 second | 256 megabytes | ['binary search', 'data structures', 'implementation', 'two pointers', '*2500'] |
D. Explorer Spacetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are wandering in the explorer space of the 2050 Conference.The explorer space can be viewed as an undirected weighted grid graph with size n\times m. The set of vertices is \{(i, j)|1\le i\le n, 1\... | 3 3 10
1 1
1 1
1 1
1 1 1
1 1 1
| 10 10 10 10 10 10 10 10 10 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'shortest paths', '*1800'] |
C. Fillomino 2time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFillomino is a classic logic puzzle. (You do not need to know Fillomino in order to solve this problem.) In one classroom in Yunqi town, some volunteers are playing a board game variant of it:Consider an n... | 3
2 3 1
| 2 2 3 3 3 1 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'greedy', 'implementation', '*1400'] |
B. Morning Joggingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe 2050 volunteers are organizing the "Run! Chase the Rising Sun" activity. Starting on Apr 25 at 7:30 am, runners will complete the 6km trail around the Yunqi town.There are n+1 checkpoints on the tr... | 2
2 3
2 3 4
1 3 5
3 2
2 3
4 1
3 5
| 2 3 4 5 3 1 2 3 4 1 3 5 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1200'] |
A. Sum of 2050time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA number is called 2050-number if it is 2050, 20500, ..., (2050 \cdot 10^k for integer k \ge 0).Given a number n, you are asked to represent n as the sum of some (not necessarily distinct) 2050-numbers. Co... | 6
205
2050
4100
20500
22550
25308639900
| -1 1 2 1 2 36 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
E. Baby Ehab Plays with Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time around, Baby Ehab will play with permutations. He has n cubes arranged in a row, with numbers from 1 to n written on them. He'll make exactly j operations. In each operatio... | 2 3
| 1 1 1 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'math', '*2500'] |
D. Cuttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following: he picks a range (l, r) and cuts the subsegment a_l, a_{... | 6 3
2 3 10 7 5 14
1 6
2 4
3 5
| 3 1 2 | 1 second | 256 megabytes | ['binary search', 'data structures', 'dp', 'graphs', 'number theory', 'two pointers', '*2100'] |
C. Baby Ehab Partitions Againtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBaby Ehab was toying around with arrays. He has an array a of length n. He defines an array to be good if there's no way to partition it into 2 subsequences such that the sum of the element... | 4
6 3 9 12
| 1 2 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'dp', 'math', '*1700'] |
B. AGAGA XOOORRRtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBaby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following operation on it: he picks 2 adjacent elements; he then removes them an... | 2
3
0 2 2
4
2 3 1 10
| YES NO | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'greedy', '*1500'] |
A. Tit for Tattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of length n, you can do at most k operations of the following type on it: choose 2 different elements in the array, add 1 to the first, and subtract 1 from the second. However, all the el... | 2
3 1
3 1 4
2 10
1 0
| 2 1 5 0 1 | 1 second | 256 megabytes | ['greedy', '*800'] |
I. Phoenix and Diamondstime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputPhoenix wonders what it is like to rob diamonds from a jewelry store!There are n types of diamonds. The i-th type has weight w_i and value v_i. The store initially has a_i diamonds of the i-th t... | 3 5
2 3 4
1 5 1
0 2 4
3 6
1 3 3
3 10
2 2 3
3 30
| 8 16 13 | 5 seconds | 1024 megabytes | ['binary search', 'data structures', 'sortings', '*3400'] |
H. Phoenix and Bitstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPhoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, \dots, a_n, and will perform q of the following queries: replace all num... | 5 6
5 4 3 2 1
1 2 3 2
4 2 5
3 2 5 3
4 1 6
2 1 1 8
4 8 10
| 3 2 1 | 4 seconds | 512 megabytes | ['bitmasks', 'brute force', 'data structures', 'sortings', '*3500'] |
G. Phoenix and Odometerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Fire City, there are n intersections and m one-way roads. The i-th road goes from intersection a_i to b_i and has length l_i miles. There are q cars that may only drive along those roads. The... | 4 4
1 2 1
2 3 1
3 1 2
1 4 3
3
1 1 3
1 2 4
4 0 1
| YES NO YES | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'math', 'number theory', '*2700'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.