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. Zero Remainder Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n positive integers.Initially, you have an integer x = 0. During one move, you can do one of the following two operations: Choose exactly one i from 1 to n... | 5
4 3
1 2 1 3
10 6
8 7 1 8 3 7 5 10 8 9
5 10
20 100 50 20 100500
10 25
24 24 24 24 24 24 24 24 24 24
8 8
1 2 3 4 5 6 7 8
| 6 18 0 227 8 | 2 seconds | 256 megabytes | ['math', 'sortings', 'two pointers', '*1400'] |
C. Move Bracketstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a bracket sequence s of length n, where n is even (divisible by two). The string s consists of \frac{n}{2} opening brackets '(' and \frac{n}{2} closing brackets ')'.In one move, you can cho... | 4
2
)(
4
()()
8
())()()(
10
)))((((())
| 1 0 1 3 | 1 second | 256 megabytes | ['greedy', 'strings', '*1000'] |
B. Multiply by 2, divide by 6time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n. In one move, you can either multiply n by two or divide n by 6 (if it is divisible by 6 without the remainder).Your task is to find the minimum number of moves ne... | 7
1
2
3
12
12345
15116544
387420489
| 0 -1 2 -1 -1 12 36 | 1 second | 256 megabytes | ['math', '*900'] |
A. Required Remaindertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integers x, y and n. Your task is to find the maximum integer k such that 0 \le k \le n that k \bmod x = y, where \bmod is modulo operation. Many programming languages use percen... | 7
7 5 12345
5 0 4
10 5 15
17 8 54321
499999993 9 1000000000
10 5 187
2 0 999999999
| 12339 0 15 54306 999999995 185 999999998 | 1 second | 256 megabytes | ['math', '*800'] |
G. Pawnstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chessboard consisting of n rows and n columns. Rows are numbered from bottom to top from 1 to n. Columns are numbered from left to right from 1 to n. The cell at the intersection of the x-th col... | 5 3 5
4 4
3 5
2 4
3 4
3 5
| 0 1 2 2 1 | 3 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'greedy', '*2600'] |
F. Network Coveragetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe government of Berland decided to improve network coverage in his country. Berland has a unique structure: the capital in the center and n cities in a circle around the capital. The capital alread... | 5
3
2 3 4
3 3 3
3
3 3 3
2 3 4
4
2 3 4 5
3 7 2 2
4
4 5 2 3
2 3 2 7
2
1 1
10 10
| YES YES NO YES YES | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', '*2400'] |
E. Sum of Digitstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet f(x) be the sum of digits of a decimal number x.Find the smallest non-negative integer x such that f(x) + f(x + 1) + \dots + f(x + k) = n.InputThe first line contains one integer t (1 \le t \le 150)... | 7
1 0
1 1
42 7
13 7
99 1
99 0
99 2
| 1 0 4 -1 599998 99999999999 7997 | 2 seconds | 512 megabytes | ['brute force', 'constructive algorithms', 'dp', 'greedy', '*2200'] |
D. Maximum Sum on Even Positionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on).You can reverse at most one sub... | 4
8
1 7 3 4 7 6 2 9
5
1 2 1 2 1
10
7 8 4 5 7 6 8 9 7 3
4
3 1 2 1
| 26 5 37 5 | 2 seconds | 256 megabytes | ['divide and conquer', 'dp', 'greedy', 'implementation', '*1600'] |
C. Pluses and Minusestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting only of characters + and -. You perform some process with this string. This process can be described by the following pseudocode: res = 0for init = 0 to inf c... | 3
--+-
---
++--+-
| 7 9 6 | 2 seconds | 256 megabytes | ['math', '*1300'] |
B. 01 Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlica and Bob are playing a game.Initially they have a binary string s consisting of only characters 0 and 1.Alice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice m... | 3
01
1111
0011
| DA NET NET | 1 second | 256 megabytes | ['games', '*900'] |
A. Donut Shopstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are two rival donut shops.The first shop sells donuts at retail: each donut costs a dollars.The second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts... | 4
5 10 4
4 5 20
2 2 3
1000000000 1000000000 1000000000
| -1 20 8 -1 1 2 -1 1000000000 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', '*1000'] |
F. Omkar and Modestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRay lost his array and needs to find it by asking Omkar. Omkar is willing to disclose that the array has the following qualities: The array has n (1 \le n \le 2 \cdot 10^5) elements. Every element i... | 6
2 2
2 2
3 2
2 1
| ? 1 6 ? 1 3 ? 4 6 ? 3 4 ! 1 2 2 3 3 4 | 3 seconds | 256 megabytes | ['binary search', 'divide and conquer', 'interactive', '*2700'] |
E. Omkar and Last Floortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar is building a house. He wants to decide how to make the floor plan for the last floor.Omkar's floor starts out as n rows of m zeros (1 \le n,m \le 100). Every row is divided into intervals ... | 4 5
2
1 2
3 5
2
1 3
4 5
3
1 1
2 4
5 5
3
1 1
2 2
3 5
| 36 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'two pointers', '*2900'] |
D. Omkar and Circletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDanny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!You are given n nonnegative integers a_1, a_2, \dots, a_n arranged in a circle... | 3
7 10 2
| 17 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'games', 'greedy', '*2100'] |
C. Omkar and Baseballtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPatrick likes to play baseball, but sometimes he will spend so many hours hitting home runs that his mind starts to get foggy! Patrick is sure that his scores across n sessions follow the identity ... | 251 2 3 4 573 2 4 5 1 6 7 | 0 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*1500'] |
B. Omkar and Last Class of Mathtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.Omkar, having a laudably ... | 3
4
6
9
| 2 2 3 3 3 6 | 1 second | 256 megabytes | ['greedy', 'math', 'number theory', '*1300'] |
A. Omkar and Completiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!An array a of length n is called complete if all elements are positive and don't exceed 10... | 2
5
4
| 1 5 3 77 12 384 384 44 44 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
F. Raging Thundertime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are a warrior fighting against the machine god Thor.Thor challenge you to solve the following problem:There are n conveyors arranged in a line numbered with integers from 1 to n from left to right.... | 5 6
><>><
2 4
3 5
1 5
1 3
2 4
1 5
| 3 3 5 3 2 3 | 3 seconds | 512 megabytes | ['data structures', 'divide and conquer', 'implementation', '*2800'] |
E2. Asterism (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference between versions is the constraints on n and a_i. You can make hacks only if all versions of the problem are solved.First, Aoi came up w... | 3 2
3 4 5
| 1 3 | 1 second | 256 megabytes | ['binary search', 'combinatorics', 'dp', 'math', 'number theory', 'sortings', '*2300'] |
E1. Asterism (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference between versions is the constraints on n and a_i. You can make hacks only if all versions of the problem are solved.First, Aoi came up w... | 3 2
3 4 5
| 1 3 | 1 second | 256 megabytes | ['binary search', 'brute force', 'combinatorics', 'math', 'number theory', 'sortings', '*1900'] |
D. Grid-00100time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!You are given integers n,k. Construct a grid A with size n \times n consisting of integers 0 and 1. The very important condi... | 4
2 2
3 8
1 0
4 16
| 0 10 01 2 111 111 101 0 0 0 1111 1111 1111 1111 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*1600'] |
C. A Cookie for Youtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has a vanilla cookies and b chocolate cookies for... | 6
2 2 1 2
0 100 0 1
12 13 25 1
27 83 14 25
0 0 1 0
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
| Yes No No Yes No Yes | 1 second | 256 megabytes | ['greedy', 'implementation', 'math', '*1300'] |
B. Magical Calendartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily 7 days!In detail, she can choose an... | 5
3 4
3 2
3 1
13 7
1010000 9999999
| 4 3 1 28 510049495001 | 1 second | 256 megabytes | ['math', '*1200'] |
A. Magical Stickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA penguin Rocher has n sticks. He has exactly one stick with length i for all 1 \le i \le n.He can connect some sticks. If he connects two sticks that have lengths a and b, he gets one stick with length... | 4
1
2
3
4
| 1 1 2 2 | 1 second | 256 megabytes | ['math', '*800'] |
F2. The Hidden Pair (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved.This is an... | 1
3
1 2
1 3
1 1
2 3
3 1
3 1
Correct | ? 1 1 ? 1 2 ? 1 3 ? 2 2 3 ! 1 3 | 2 seconds | 256 megabytes | ['binary search', 'dfs and similar', 'graphs', 'interactive', 'shortest paths', 'trees', '*2700'] |
F1. The Hidden Pair (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved.This is an... | 1
3
1 2
1 3
1 1
2 3
3 1
3 1
Correct | ? 1 1 ? 1 2 ? 1 3 ? 2 2 3 ! 1 3 | 2 seconds | 256 megabytes | ['binary search', 'dfs and similar', 'graphs', 'interactive', 'shortest paths', 'trees', '*2400'] |
E. Binary Subsequence Rotationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNaman has two binary strings s and t of length n (a binary string is a string which only consists of the characters "0" and "1"). He wants to convert s into t using the following operation... | 6
010000
000001
| 1 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', '*2100'] |
D. Odd-Even Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish has an array a of size n.A subsequence of a is defined as a sequence that can be obtained from a by deleting some elements (possibly none), without changing the order of the remaining elem... | 4 2
1 2 3 4
| 1 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'dsu', 'greedy', 'implementation', '*2000'] |
C. Number Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshishgup and FastestFinger play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: Divide n by any of its odd divisors greater than 1. ... | 7
1
2
3
4
5
6
12
| FastestFinger Ashishgup Ashishgup FastestFinger Ashishgup FastestFinger Ashishgup | 2 seconds | 256 megabytes | ['games', 'math', 'number theory', '*1400'] |
B. GCD Compressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish has an array a of consisting of 2n positive integers. He wants to compress a into an array b of size n-1. To do this, he first discards exactly 2 (any two) elements from a. He then performs the ... | 3
3
1 2 3 4 5 6
2
5 7 9 10
5
1 3 3 4 5 90 100 101 2 3
| 3 6 4 5 3 4 1 9 2 3 4 5 6 10 | 1 second | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1100'] |
A. Maximum GCDtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider all integers in the range from 1 to n (inclusive).Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find th... | 2
3
5
| 1 2 | 1 second | 256 megabytes | ['greedy', 'implementation', 'math', 'number theory', '*800'] |
F. BareLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...Th... | 3
5 8
1 4
3 10
| 1 1 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'games', '*2700'] |
E. DeadLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee bought some food for dinner time, but Lee's friends eat dinner in a deadly way. Lee is so scared, he doesn't want to die, at least not before seeing Online IOI 2020...There are n different types of food a... | 3 3
1 2 1
1 2
2 3
1 3
| ALIVE 3 2 1 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'greedy', 'implementation', 'sortings', '*2400'] |
D. TediousLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee tried so hard to make a good div.2 D problem to balance his recent contest, but it still doesn't feel good at all. Lee invented it so tediously slow that he managed to develop a phobia about div.2 D pr... | 7
1
2
3
4
5
100
2000000
| 0 0 4 4 12 990998587 804665184 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'greedy', 'math', 'trees', '*1900'] |
C. RationalLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought n integers, now it's time to distribute them between his friends rationally...Lee has n integers a_1,... | 3
4 2
1 13 7 17
1 3
6 2
10 10 10 10 11 11
3 3
4 4
1000000000 1000000000 1000000000 1000000000
1 1 1 1
| 48 42 8000000000 | 2 seconds | 256 megabytes | ['greedy', 'math', 'sortings', 'two pointers', '*1400'] |
B. AccurateLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...The string s he found is a binary string of length... | 5
10
0001111111
4
0101
8
11001101
10
1110000000
1
1
| 0001111111 001 01 0 1 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'strings', '*1200'] |
A. FashionabLeetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLee is going to fashionably decorate his house for a party, using some regular convex polygons...Lee thinks a regular n-sided (convex) polygon is beautiful if and only if he can rotate it in such a way t... | 4
3
4
12
1000000000
| NO YES YES YES | 2 seconds | 256 megabytes | ['geometry', 'math', '*800'] |
H2. Breadboard Capacity (hard version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is a harder version of the problem H with modification queries.Lester and Delbert work at an electronics company. They are currently working on a microchip component serving t... | 4 5 4
BBRR
RBBR
BBBBB
RRRRR
L 2 3
R 3 4
U 1 5
D 1 5
| 7 7 9 4 9 | 2 seconds | 512 megabytes | ['*3500'] |
H1. Breadboard Capacity (easy version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem H without modification queries.Lester and Delbert work at an electronics company. They are currently working on a microchip component servi... | 4 5 0
BBRR
RBBR
BBBBB
RRRRR
| 7 | 2 seconds | 512 megabytes | ['dp', 'flows', 'greedy', '*3300'] |
G. Shifting Dominoestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBill likes to play with dominoes. He took an n \times m board divided into equal square cells, and covered it with dominoes. Each domino covers two adjacent cells of the board either horizontally or... | 2 4
UUUU
DDDD
| 4 | 2 seconds | 512 megabytes | ['data structures', 'geometry', 'graphs', 'trees', '*3200'] |
F. Lamps on a Circletime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.John and his imaginary friend play a game. There are n lamps arranged in a circle. Lamps are numbered 1 through n in clockwise order, that is, lamps i and i + 1 are ad... | 3
| 0 | 2 seconds | 512 megabytes | ['games', 'implementation', 'interactive', 'math', '*2600'] |
E. Ski Accidentstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputArthur owns a ski resort on a mountain. There are n landing spots on the mountain numbered from 1 to n from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. ... | 2
4 6
1 2
1 3
2 3
2 4
3 4
3 4
7 6
1 2
1 3
2 4
2 5
3 6
3 7
| 2 3 4 4 4 5 6 7 | 2 seconds | 512 megabytes | ['constructive algorithms', 'graphs', 'greedy', '*2500'] |
D. AND, OR and square sumtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGottfried learned about binary number representation. He then came up with this task and presented it to you.You are given a collection of n non-negative integers a_1, \ldots, a_n. You are allo... | 1
123
| 15129 | 2 seconds | 512 megabytes | ['bitmasks', 'greedy', 'math', '*1700'] |
C. Even Picturetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLeo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction.To draw a p... | 4
| 12 1 0 2 0 0 1 1 1 2 1 3 1 0 2 1 2 2 2 3 2 1 3 2 3 | 2 seconds | 512 megabytes | ['constructive algorithms', '*1500'] |
B. Codeforces Subsequencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputKarl likes Codeforces and subsequences. He wants to find a string of lowercase English letters that contains at least k subsequences codeforces. Out of all possible strings, Karl wants to find... | 1
| codeforces | 2 seconds | 512 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', 'strings', '*1500'] |
A. C+=time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLeo has developed a new programming language C+=. In C+=, integer variables can only be changed with a "+=" operation that adds the right-hand side value to the left-hand side variable. For example, performing "a... | 2
1 2 3
5 4 100
| 2 7 | 2 seconds | 512 megabytes | ['brute force', 'greedy', 'implementation', 'math', '*800'] |
F2. Flying Sort (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. In this version, the given array can contain equal elements and the constraints on n are greater than in the easy version of the problem.You are give... | 9
5
4 7 2 2 9
5
3 5 8 1 7
5
1 2 2 4 5
2
0 1
3
0 1 0
4
0 1 0 0
4
0 1 0 1
4
0 1 0 2
20
16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9 10 20 0 9
| 2 2 0 0 1 1 1 1 16 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', 'greedy', 'sortings', 'two pointers', '*2400'] |
F1. Flying Sort (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. In this version, all numbers in the given array are distinct and the constraints on n are less than in the hard version of the problem.You are given... | 4
5
4 7 2 3 9
5
3 5 8 1 7
5
1 4 5 7 12
4
0 2 1 3
| 2 2 0 2 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'two pointers', '*2100'] |
E. Necklace Assemblytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe store sells n beads. The color of each bead is described by a lowercase letter of the English alphabet ("a"–"z"). You want to buy some beads to assemble a necklace from them.A necklace is a set ... | 6
6 3
abcbac
3 6
aaa
7 1000
abczgyo
5 4
ababa
20 10
aaebdbabdbbddaadaadc
20 5
ecbedececacbcbccbdec
| 6 3 5 4 15 10 | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dp', 'graphs', 'greedy', 'number theory', '*1900'] |
D. Task On The Boardtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.After that, he erased some letters from the string s, an... | 4
abac
3
2 1 0
abc
1
0
abba
3
1 0 1
ecoosdcefr
10
38 13 24 14 11 5 3 24 17 0
| aac b aba codeforces | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'sortings', '*1800'] |
C. Social Distancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp and his friends want to visit a new restaurant. The restaurant has n tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from 1 to n in t... | 6
6 1
100010
6 2
000000
5 1
10101
3 1
001
2 2
00
1 1
0
| 1 2 0 1 1 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1300'] |
B. Even Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a[0 \ldots n-1] of length n which consists of non-negative integers. Note that array indices start from zero.An array is called good if the parity of each index matches the parity of... | 4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0
| 2 1 -1 0 | 2 seconds | 256 megabytes | ['greedy', 'math', '*800'] |
A. Short Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice guesses the strings that Bob made for her.At first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from s... | 4
abbaac
ac
bccddaaf
zzzzzzzzzz
| abac ac bcdaf zzzzzz | 2 seconds | 256 megabytes | ['implementation', 'strings', '*800'] |
G. Construct the Stringtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's denote the function f(s) that takes a string s consisting of lowercase Latin letters and dots, and returns a string consisting of lowercase Latin letters as follows: let r be an empty stri... | a.ba.b.
abb
| 2 | 4 seconds | 512 megabytes | ['data structures', 'dp', 'strings', '*2700'] |
F. Jog Around The Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a simple weighted connected undirected graph, consisting of n vertices and m edges.A path in the graph of length k is a sequence of k+1 vertices v_1, v_2, \dots, v_{k+1} such that f... | 7 8 25
1 2 1
2 3 10
3 4 2
1 5 2
5 6 7
6 4 15
5 3 1
1 7 3
| 4361 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'geometry', 'graphs', '*2700'] |
E. Two Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a_1, a_2, \dots , a_n and b_1, b_2, \dots , b_m. Array b is sorted in ascending order (b_i < b_{i + 1} for each i from 1 to m - 1).You have to divide the array a into m consecutive... | 6 3
12 10 20 20 25 30
10 20 30
| 2 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'combinatorics', 'constructive algorithms', 'dp', 'two pointers', '*2100'] |
D. Two Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \dots, a_n.For each a_i find its two divisors d_1 > 1 and d_2 > 1 such that \gcd(d_1 + d_2, a_i) = 1 (where \gcd(a, b) is the greatest common divisor of a and b) or say... | 10
2 3 4 5 6 7 8 9 10 24
| -1 -1 -1 -1 3 -1 -1 -1 2 2 -1 -1 -1 -1 2 -1 -1 -1 5 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*2000'] |
C. Palindromic Pathstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a matrix with n rows (numbered from 1 to n) and m columns (numbered from 1 to m). A number a_{i, j} is written in the cell belonging to the i-th row and the j-th column, each number ... | 4
2 2
1 1
0 1
2 3
1 1 0
1 0 0
3 7
1 0 1 1 1 1 1
0 0 0 0 0 0 0
1 1 1 1 1 0 1
3 5
1 0 1 0 0
1 1 1 1 0
0 0 1 0 0
| 0 3 4 4 | 1.5 seconds | 256 megabytes | ['greedy', 'math', '*1500'] |
B. Shuffletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array consisting of n integers a_1, a_2, ..., a_n. Initially a_x = 1, all other elements are equal to 0.You have to perform m operations. During the i-th operation, you choose two indices c an... | 3
6 4 3
1 6
2 3
5 5
4 1 2
2 4
1 2
3 3 2
2 3
1 2
| 6 2 3 | 1 second | 256 megabytes | ['math', 'two pointers', '*1300'] |
A. Shovels and Swordstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamo... | 4
4 4
1000000000 0
7 15
8 7
| 2 0 7 5 | 1 second | 256 megabytes | ['binary search', 'greedy', 'math', '*1100'] |
G. Secure Passwordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Ayush devised yet another scheme to set the password of his lock. The lock has n slots where each slot can hold any non-negative integer. The password P is a sequence of... | 3
1
2
4
| ? 1 1 ? 1 2 ? 1 3 ! 6 5 3 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'constructive algorithms', 'interactive', 'math', '*2800'] |
F. Swaps Againtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAyush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.Each test case consists of an integer n and two arrays a and b, ... | 5
2
1 2
2 1
3
1 2 3
1 2 3
3
1 2 4
1 3 4
4
1 2 3 2
3 1 2 2
3
1 2 3
1 3 2
| yes yes No yes No | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'sortings', '*2100'] |
E. Maximum Subsequence Valuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRidhiman challenged Ashish to find the maximum valued subsequence of an array a of size n consisting of positive integers. The value of a non-empty subsequence of k elements of a is defined ... | 3
2 1 3
| 3 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', '*1900'] |
D. Solve The Mazetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVivek has encountered a problem. He has a maze that can be represented as an n \times m grid. Each of the grid cells may represent the following: Empty — '.' Wall — '#' Good person — 'G' Bad person... | 6
1 1
.
1 2
G.
2 2
#B
G.
2 3
G.#
B#.
3 3
#B.
#..
GG.
2 2
#B
B.
| Yes Yes No No Yes Yes | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'implementation', 'shortest paths', '*1700'] |
C. Rotation Matchingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation ... | 5
1 2 3 4 5
2 3 4 5 1
| 5 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'implementation', '*1400'] |
B. Trouble Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish has n elements arranged in a line. These elements are represented by two integers a_i — the value of the element and b_i — the type of the element (there are only two possible types: 0 and 1). He w... | 5
4
10 20 20 30
0 1 0 1
3
3 1 2
0 1 1
4
2 2 4 8
1 1 1 1
3
5 15 4
0 0 0
4
20 10 100 50
1 0 0 1
| Yes Yes Yes No Yes | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*1300'] |
A. Matrix Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish and Vivek play a game on a matrix consisting of n rows and m columns, where they take turns claiming cells. Unclaimed cells are represented by 0, while claimed cells are represented by 1. The initia... | 4
2 2
0 0
0 0
2 2
0 0
0 1
2 3
1 0 1
1 1 0
3 3
1 0 0
0 0 0
1 0 0
| Vivek Ashish Vivek Ashish | 1 second | 256 megabytes | ['games', 'greedy', 'implementation', '*1100'] |
E. X-ORtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem!Ehab has a hidden permutation p of length n consisting of the elements from 0 to n-1. You, for some reason, want to figure out the permutation. To do that, you can give Ehab 2 diffe... | 3
1
3
2 | ? 1 2 ? 1 3 ? 2 3 ! 1 0 2 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'divide and conquer', 'interactive', 'probabilities', '*2700'] |
D. Ehab's Last Corollarytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a connected undirected graph with n vertices and an integer k, you have to either: either find an independent set that has exactly \lceil\frac{k}{2}\rceil vertices. or find a simple cycle ... | 4 4 3
1 2
2 3
3 4
4 1
| 1 1 3 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'greedy', 'implementation', 'trees', '*2100'] |
C. Ehab and Prefix MEXstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of length n, find another array, b, of length n such that: for each i (1 \le i \le n) MEX(\{b_1, b_2, \ldots, b_i\})=a_i. The MEX of a set of integers is the smallest non-negativ... | 3
1 2 3
| 0 1 2 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', '*1600'] |
B. Most socially-distanced subsequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a permutation p of length n, find its subsequence s_1, s_2, \ldots, s_k of length at least 2 such that: |s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k| is as big as possible over al... | 2
3
3 2 1
4
1 3 4 2
| 2 3 1 3 1 4 2 | 1 second | 256 megabytes | ['greedy', 'two pointers', '*1300'] |
A. XXXXXtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEhab loves number theory, but for some reason he hates the number x. Given an array a, find the length of its longest subarray such that the sum of its elements isn't divisible by x, or determine that such subar... | 3
3 3
1 2 3
3 4
1 2 3
2 2
0 6
| 2 3 -1 | 1 second | 256 megabytes | ['brute force', 'data structures', 'number theory', 'two pointers', '*1200'] |
F. Rotating Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings s and t, each of length n and consisting of lowercase Latin alphabets. You want to make s equal to t. You can perform the following operation on s any number of times to ... | 6
1
a
a
2
ab
ba
3
abc
cab
3
abc
cba
4
abab
baba
4
abcc
aabc
| 0 1 1 2 1 -1 | 2 seconds | 256 megabytes | ['dp', 'strings', '*2600'] |
E. Tree Shufflingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAshish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in t... | 5
1 0 1
20 1 0
300 0 1
4000 0 0
50000 1 0
1 2
2 3
2 4
1 5
| 4 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'greedy', 'trees', '*2000'] |
D. Guess The Maximumstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Ayush devised a new scheme to set the password of his lock. The lock has k slots where each slot can hold integers from 1 to n. The password P is a sequence of k inte... | 1
4 2
2 1 3
2 2 4
1
2
3
4
Correct | ? 1 1 ? 1 2 ? 1 3 ? 1 4 ! 4 3 | 2 seconds | 256 megabytes | ['binary search', 'implementation', 'interactive', 'math', '*2100'] |
C. Game On Leavestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAyush and Ashish play a game on an unrooted tree consisting of n nodes numbered 1 to n. Players make the following move in turns: Select any leaf node in the tree and remove it together with any edge... | 1
3 1
2 1
3 1
| Ashish | 2 seconds | 256 megabytes | ['games', 'trees', '*1600'] |
B. Subsequence Hatetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputShubham has a binary string s. A binary string is a string containing only characters "0" and "1".He can perform the following operation on the string any amount of times: Select an index of the str... | 7
001
100
101
010
0
1
001100
| 0 0 1 1 0 0 2 | 1 second | 256 megabytes | ['implementation', 'strings', '*1400'] |
A. Odd Selectiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputShubham has an array a of size n, and wants to select exactly x elements from it, such that their sum is odd. These elements do not have to be consecutive. The elements of the array are not guaranteed to... | 5
1 1
999
1 1
1000
2 1
51 50
2 2
51 50
3 3
101 102 103
| Yes No Yes Yes No | 1 second | 256 megabytes | ['brute force', 'implementation', 'math', '*1200'] |
C. Johnny and Another Rating Droptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented ... | 5
5
7
11
1
2000000000000
| 8 11 19 1 3999999999987 | 1 second | 256 megabytes | ['bitmasks', 'greedy', 'math', '*1400'] |
B. Johnny and His Hobbiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAmong Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is u... | 6
4
1 0 2 3
6
10 7 14 8 3 12
2
0 2
3
1 2 3
6
1 4 6 10 11 12
2
0 1023
| 1 4 2 -1 -1 1023 | 1 second | 256 megabytes | ['bitmasks', 'brute force', '*1200'] |
A. Johnny and Ancient Computertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohnny has recently found an ancient, broken computer. The machine has only one register, which allows one to put in there one variable. Then in one operation, you can shift its bits left o... | 10
10 5
11 44
17 21
1 1
96 3
2 128
1001 1100611139403776
1000000000000000000 1000000000000000000
7 1
10 8
| 1 1 -1 0 2 2 14 0 -1 -1 | 1 second | 256 megabytes | ['implementation', '*1000'] |
F. Johnny and New Toytime limit per test15 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputJohnny has a new toy. As you may guess, it is a little bit extraordinary. The toy is a permutation P of numbers from 1 to n, written in one row next to each other. For each i from 1 to n - 1 betw... | 3
3 2 1
2 1
3
1 3
3 2
3 1
| 0 1 0 | 15 seconds | 1024 megabytes | ['data structures', 'implementation', 'math', '*3300'] |
E. James and the Chasetime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJames Bond has a new plan for catching his enemy. There are some cities and directed roads between them, such that it is possible to travel between any two cities using these roads. When the ene... | 4
3 3
1 2
2 3
3 1
3 6
1 2
2 1
2 3
3 2
1 3
3 1
7 10
1 2
2 3
3 1
1 4
4 5
5 1
4 6
6 7
7 4
6 1
6 8
1 2
2 3
3 4
4 5
5 6
6 1
6 2
5 1
| 1 2 3 -1 1 2 3 5 -1 | 2.5 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'probabilities', 'trees', '*3000'] |
D. Johnny and Jamestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJames Bond, Johnny's favorite secret agent, has a new mission. There are n enemy bases, each of them is described by its coordinates so that we can think about them as points in the Cartesian plane. ... | 6 2
0 0
1 1
2 2
3 3
0 1
0 2
| 6.24264069 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', 'trees', '*2900'] |
C. Johnny and Megan's Necklacetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputJohnny's younger sister Megan had a birthday recently. Her brother has bought her a box signed as "Your beautiful necklace — do it yourself!". It contains many necklace parts and some magi... | 5
13 11
11 1
3 5
17 1
9 27
| 3 8 7 9 10 5 6 1 2 3 4 | 3 seconds | 512 megabytes | ['binary search', 'bitmasks', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', '*2500'] |
B. Johnny and Grandmastertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohnny has just found the new, great tutorial: "How to become a grandmaster?". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very impo... | 4
5 2
2 3 4 4 3
3 1
2 10 1000
4 5
0 1 1 100
1 8
89
| 4 1 146981438 747093407 | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'math', 'sortings', '*1900'] |
A. Johnny and Contributiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday Johnny wants to increase his contribution. His plan assumes writing n blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references t... | 3 3
1 2
2 3
3 1
2 1 3
| 2 1 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'sortings', '*1700'] |
H. Binary Mediantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider all binary strings of length m (1 \le m \le 60). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, th... | 5
3 3
010
001
111
4 3
000
111
100
011
1 1
1
1 1
0
3 2
00
01
10
| 100 010 0 1 11 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'constructive algorithms', '*2100'] |
G. A/B Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four positive integers n, m, a, b (1 \le b \le n \le 50; 1 \le a \le m \le 50). Find any such rectangular matrix of size n \times m that satisfies all of the following conditions: each row o... | 5
3 6 2 1
2 2 2 1
2 2 2 2
4 4 2 2
2 1 1 2
| YES 010001 100100 001010 NO YES 11 11 YES 1100 1100 0011 0011 YES 1 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1900'] |
F. Spy-stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings a_1, a_2, \ldots, a_n: all of them have the same length m. The strings consist of lowercase English letters.Find any string s of length m such that each of the given n strings diffe... | 5
2 4
abac
zbab
2 4
aaaa
bbbb
3 3
baa
aaa
aab
2 2
ab
bb
3 1
a
b
c
| abab -1 aaa ab z | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dp', 'hashing', 'strings', '*1700'] |
E. Polygontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolygon is not only the best platform for developing problems but also a square matrix with side n, initially filled with the character 0.On the polygon, military training was held. The soldiers placed a cann... | 5
4
0010
0011
0000
0000
2
10
01
2
00
00
4
0101
1111
0101
0111
4
0100
1110
0101
0111
| YES NO YES YES NO | 2 seconds | 256 megabytes | ['dp', 'graphs', 'implementation', 'shortest paths', '*1300'] |
D. Buying Shovelstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the i-th type consists of exactly i shovels (1 \le i \le k). The store h... | 5
8 7
8 1
6 10
999999733 999999732
999999733 999999733
| 2 8 1 999999733 1 | 2 seconds | 256 megabytes | ['math', 'number theory', '*1300'] |
C. Similar Pairstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe call two numbers x and y similar if they have the same parity (the same remainder when divided by 2), or if |x-y|=1. For example, in each of the pairs (2, 6), (4, 3), (11, 7), the numbers are similar... | 7
4
11 14 16 12
2
1 8
4
1 1 1 1
4
1 2 5 6
2
12 13
6
1 6 3 10 5 8
6
1 12 3 10 5 8
| YES NO YES YES YES YES NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'graph matchings', 'greedy', 'sortings', '*1100'] |
B. Honest Coachtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete — the athlete number i has the strength s_i.You want to split all athlete... | 5
5
3 1 2 6 4
6
2 1 3 2 4 3
4
7 9 3 1
2
1 1000
3
100 150 200
| 1 0 2 999 50 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*800'] |
A. Minimal Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFind the minimum area of a square land on which you can place two identical rectangular a \times b houses. The sides of the houses should be parallel to the sides of the desired square land.Formally, ... | 8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
| 16 16 4 9 64 9 64 40000 | 2 seconds | 256 megabytes | ['greedy', 'math', '*800'] |
F. RC Kaboom Showtime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou know, it's hard to conduct a show with lots of participants and spectators at the same place nowadays. Still, you are not giving up on your dream to make a car crash showcase! You decided to replac... | 4
3 -1 -1 1 2
2 3 -3 -2 10
-4 2 1 -2 1
-2 -2 -1 2 4
| 0.585902082262898 | 6 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'geometry', 'math', '*2900'] |
E. Modular Stabilitytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe define x \bmod y as the remainder of division of x by y (\% operator in C++ or Java, mod operator in Pascal).Let's call an array of positive integers [a_1, a_2, \dots, a_k] stable if for every pe... | 7 3
| 16 | 2 seconds | 512 megabytes | ['combinatorics', 'math', 'number theory', '*2000'] |
D. Yet Another Yet Another Tasktime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing yet another card game. This time the rules are the following. There are n cards lying in a row in front of them. The i-th card has value a_i. First, Alice choo... | 5
5 -2 10 -1 4
| 6 | 1.5 seconds | 512 megabytes | ['data structures', 'dp', 'implementation', 'two pointers', '*2000'] |
C. Mixing Watertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are two infinite sources of water: hot water of temperature h; cold water of temperature c (c < h). You perform the following procedure of alternating moves: take one cup of the hot water and po... | 3
30 10 20
41 15 30
18 13 18
| 2 7 1 | 2 seconds | 256 megabytes | ['binary search', 'math', '*1700'] |
B. New Theatre Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou might have remembered Theatre square from the problem 1A. Now it's finally getting repaved.The square still has a rectangular shape of n \times m meters. However, the picture is about to get mo... | 4
1 1 10 1
.
1 2 10 1
..
2 1 10 1
.
.
3 3 3 7
..*
*..
.*.
| 10 1 20 18 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'implementation', 'two pointers', '*1000'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.