task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Wet Shark and Blocks Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *b* blocks of digits. Each one consisting of the same *n* digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together ...
5,100
Title: Economy Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0....
5,101
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string *s* consisting of *n* lowercase English letters. There is a filler word ogo i...
5,102
Title: Balance Time Limit: 3 seconds Memory Limit: 128 megabytes Problem Description: Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations: - t...
5,103
Title: Palisection Time Limit: 2 seconds Memory Limit: 128 megabytes Problem Description: In an English class Nick had nothing to do at all, and remembered about wonderful strings called palindromes. We should remind you that a string is called a palindrome if it can be read the same way both from left to right and ...
5,104
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must. Little Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this... Given...
5,105
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Qwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to get to the planet as soon as possible...
5,106
Title: One-Dimensional Battle Ships Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of *n* square cells (that is, on a 1<=×<=*n* table). At the beginning of the game Alice puts...
5,107
Title: Karen and Cards Time Limit: None seconds Memory Limit: None megabytes Problem Description: Karen just got home from the supermarket, and is getting ready to go to sleep. After taking a shower and changing into her pajamas, she looked at her shelf and saw an album. Curious, she opened it and saw a trading car...
5,108
Title: Road Improvement Time Limit: None seconds Memory Limit: None megabytes Problem Description: In Berland there are *n* cities and *n*<=-<=1 bidirectional roads. Each road connects some pair of cities, from any city you can get to any other one using only the given roads. In each city there is exactly one repai...
5,109
Title: Bear and Square Grid Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have a grid with *n* rows and *n* columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). Two empty cells are directly connected if they share a side. Two cells (*r*1,<=*c*1) (located ...
5,110
Title: Buying A House Time Limit: None seconds Memory Limit: None megabytes Problem Description: Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us. The girl lives in house *m* of a village. There are *n* houses in that village, lining in a straight li...
5,111
Title: Bear and Displayed Friends Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. He loves connecting with other bears via social networks. He has *n* friends and his relation with the *i*-th of them is described by a unique integer *t**i*. The bigger this val...
5,112
Title: Counting Skyscrapers Time Limit: None seconds Memory Limit: None megabytes Problem Description: A number of skyscrapers have been built in a line. The number of skyscrapers was chosen uniformly at random between 2 and 314! (314 factorial, a very large number). The height of each skyscraper was chosen randomly...
5,113
Title: Lefthanders and Righthanders Time Limit: None seconds Memory Limit: None megabytes Problem Description: One fine October day a mathematics teacher Vasily Petrov went to a class and saw there *n* pupils who sat at the desks, two people at each desk. Vasily quickly realized that number *n* is even. Like all t...
5,114
Title: Generating Sets Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a set *Y* of *n* distinct positive integers *y*1,<=*y*2,<=...,<=*y**n*. Set *X* of *n* distinct positive integers *x*1,<=*x*2,<=...,<=*x**n* is said to generate set *Y* if one can transform *X* to *Y* by ...
5,115
Title: Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it. There is integer *n* and array *a*, consistin...
5,116
Title: Haiku Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase...
5,117
Title: Broken checker Time Limit: None seconds Memory Limit: None megabytes Problem Description: "This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!" — people complained in the comments to one round on Codeforces. And even more... No,...
5,118
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: th...
5,119
Title: Students in Railway Carriage Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger. The university team for the Olympiad consists of $a$ student-programmers and $b$ student-...
5,120
Title: Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Furik and Rubik love playing computer games. Furik has recently found a new game that greatly interested Rubik. The game consists of *n* parts and to complete each part a player may probably need to complete some other ones. We kn...
5,121
Title: Greedy Petya Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya is an unexperienced programming contestant. Recently he has come across the following problem: You are given a non-directed graph which consists of *n* nodes and *m* edges. Your task is to determine whether the grap...
5,122
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of *n* small Latin letters; the task was to learn the way the letters that the s...
5,123
Title: Berland and the Shortest Paths Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are $n$ cities in Berland. Some pairs of cities are connected by roads. All roads are bidirectional. Each road connects two different cities. There is at most one road between a pair of cities. The ...
5,124
Title: Infinite Maze Time Limit: None seconds Memory Limit: None megabytes Problem Description: We've got a rectangular *n*<=×<=*m*-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze and cyclically tiled a plane with it so that the plane became an infinite maze. Now on th...
5,125
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given ...
5,126
Title: Mike and Chocolate Thieves Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thi...
5,127
Title: Very simple problem Time Limit: 3 seconds Memory Limit: 256 megabytes Problem Description: You are given a convex polygon. Count, please, the number of triangles that contain a given point in the plane and their vertices are the vertices of the polygon. It is guaranteed, that the point doesn't lie on the side...
5,128
Title: Army Creation Time Limit: None seconds Memory Limit: None megabytes Problem Description: As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires. In the game Vova can hire *n* different warriors; *i*th warrior has the type *...
5,129
Title: Maximal GCD Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given positive integer number *n*. You should create such strictly increasing sequence of *k* positive numbers *a*1,<=*a*2,<=...,<=*a**k*, that their sum is equal to *n* and greatest common divisor is maximal. Grea...
5,130
Title: Postcards and photos Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the r...
5,131
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable...
5,132
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Jzzhu has a big rectangular chocolate bar that consists of *n*<=×<=*m* unit squares. He wants to cut this bar exactly *k* times. Each cut must meet the following requirements: - each cut should be straight (horizontal or vertica...
5,133
Title: Supercollider Time Limit: None seconds Memory Limit: None megabytes Problem Description: This problem consists of two subproblems: for solving subproblem D1 you will receive 3 points, and for solving subproblem D2 you will receive 16 points. Manao is the chief architect involved in planning a new supercollid...
5,134
Title: Track Time Limit: 5 seconds Memory Limit: 256 megabytes Problem Description: You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to compl...
5,135
Title: Iterated Linear Function Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider a linear function *f*(*x*)<==<=*Ax*<=+<=*B*. Let's define *g*(0)(*x*)<==<=*x* and *g*(*n*)(*x*)<==<=*f*(*g*(*n*<=-<=1)(*x*)) for *n*<=&gt;<=0. For the given integer values *A*, *B*, *n* and *x* find th...
5,136
Title: Painting Fence Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as *n* vertical planks, put in a row. Adjacent...
5,137
Title: Quiz Time Limit: None seconds Memory Limit: None megabytes Problem Description: Manao is taking part in a quiz. The quiz consists of *n* consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correct...
5,138
Title: Sausage Maximization Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They have their own...
5,139
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have matrix *a* of size *n*<=×<=*n*. Let's number the rows of the matrix from 1 to *n* from top to bottom, let's number the columns from 1 to *n* from left to right. Let's use *a**ij* to represent the element on the intersecti...
5,140
Title: Domino piling Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as p...
5,141
Title: Two progressions Time Limit: None seconds Memory Limit: None megabytes Problem Description: An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 1...
5,142
Title: Generate Login Time Limit: None seconds Memory Limit: None megabytes Problem Description: The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the fu...
5,143
Title: Pashmak and Flowers Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pashmak decided to give Parmida a pair of flowers from the garden. There are *n* flowers in the garden and the *i*-th of them has a beauty number *b**i*. Parmida is a very strange girl so she doesn't want to have th...
5,144
Title: Packmen Strike Back Time Limit: None seconds Memory Limit: None megabytes Problem Description: Game field is represented by a line of *n* square cells. In some cells there are packmen, in some cells there are asterisks and the rest of the cells are empty. Packmen eat asterisks. Before the game starts you can...
5,145
Title: Tournament Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently a tournament in *k* kinds of sports has begun in Berland. Vasya wants to make money on the bets. The scheme of the tournament is very mysterious and not fully disclosed. Competitions are held back to back, each of ...
5,146
Title: Prime Number Time Limit: None seconds Memory Limit: None megabytes Problem Description: Simon has a prime number *x* and an array of non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common den...
5,147
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Профиль горного хребта схематично задан в виде прямоугольной таблицы из символов «.» (пустое пространство) и «*» (часть горы). Каждый столбец таблицы содержит хотя бы одну «звёздочку». Гарантируется, что любой из символов «*» либо...
5,148
Title: Strongly Connected City Time Limit: None seconds Memory Limit: None megabytes Problem Description: Imagine a city with *n* horizontal streets crossing *m* vertical streets, forming an (*n*<=-<=1)<=×<=(*m*<=-<=1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one...
5,149
Title: Classroom Watch Time Limit: None seconds Memory Limit: None megabytes Problem Description: Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number *n*. He asked what is this number and the teacher of mathematics Inna Petrovna answe...
5,150
Title: Bear and Elections Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland. There are *n* candidates, including Limak. We know how many citizens are going to vote for e...
5,151
Title: Simple Skewness Time Limit: None seconds Memory Limit: None megabytes Problem Description: Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of *n* (not necessarily distinct) integers. Find the non-empty subset (with repetition) with the m...
5,152
Title: MYSTERIOUS LANGUAGE Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this langu...
5,153
Title: Labelling Cities Time Limit: None seconds Memory Limit: None megabytes Problem Description: Oleg the bank client lives in Bankopolia. There are *n* cities in Bankopolia and some pair of cities are connected directly by bi-directional roads. The cities are numbered from 1 to *n*. There are a total of *m* roads...
5,154
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The last stage of Football World Cup is played using the play-off system. There are *n* teams left in this stage, they are enumerated from 1 to *n*. Several rounds are held, in each round the remaining teams are sorted in the ord...
5,155
Title: Winter Is Coming Time Limit: None seconds Memory Limit: None megabytes Problem Description: The winter in Berland lasts *n* days. For each day we know the forecast for the average air temperature that day. Vasya has a new set of winter tires which allows him to drive safely no more than *k* days at any aver...
5,156
Title: Mahmoud and a Dictionary Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mahmoud wants to write a new dictionary that contains *n* words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean ...
5,157
Title: Arya and Bran Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies. At first, Arya and Bran have 0 Candies. There are *n* days, at the *i*-th day, Arya finds *a**...
5,158
Title: Cloning Toys Time Limit: None seconds Memory Limit: None megabytes Problem Description: Imp likes his plush toy a lot. Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applie...
5,159
Title: Vanya and Table Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vany...
5,160
Title: Alphabetic Removals Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times: - if there is...
5,161
Title: Haar Features Time Limit: None seconds Memory Limit: None megabytes Problem Description: The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we...
5,162
Title: Lovely Palindromes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not. Pari is tr...
5,163
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant loves playing with arrays. He has array *a*, consisting of *n* positive integers, indexed from 1 to *n*. Let's denote the number with index *i* as *a**i*. Additionally the Little Elephant has *m* queries to t...
5,164
Title: TCMCF+++ Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Vasya has gotten interested in programming contests in TCMCF+++ rules. On the contest *n* problems were suggested and every problem had a cost — a certain integral number of points (perhaps, negative or even equal to zero). Accord...
5,165
Title: Cupboards Time Limit: None seconds Memory Limit: None megabytes Problem Description: One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any long...
5,166
Title: Preparing Olympiad Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have *n* problems. You have estimated the difficulty of the *i*-th one as integer *c**i*. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest ...
5,167
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours! Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an *a*<=×<=...
5,168
Title: Sign Posts Time Limit: None seconds Memory Limit: None megabytes Problem Description: One Khanate had a lot of roads and very little wood. Riding along the roads was inconvenient, because the roads did not have road signs indicating the direction to important cities. The Han decided that it's time to fix the...
5,169
Title: Round Marriage Time Limit: None seconds Memory Limit: None megabytes Problem Description: It's marriage season in Ringland! Ringland has a form of a circle's boundary of length $L$. There are $n$ bridegrooms and $n$ brides, and bridegrooms decided to marry brides. Of course, each bridegroom should choose ex...
5,170
Title: Guess the Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iah...
5,171
Title: Board Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from ...
5,172
Title: Conan and Agasa play a Card Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has *n* cards, and the *i*-th card has a number *a**i* written on it....
5,173
Title: The Great Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. ...
5,174
Title: Selection of Personnel Time Limit: None seconds Memory Limit: None megabytes Problem Description: One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received *n* resumes. Now the HR ...
5,175
Title: Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths Time Limit: None seconds Memory Limit: None megabytes Problem Description: Just in case somebody missed it: we have wonderful girls in Arpa’s land. Arpa has a rooted tree (connected acyclic graph) consisting of *n* vertices. The vertices are numbered...
5,176
Title: Furukawa Nagisa's Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day, Okazaki Tomoya has bought a tree for Furukawa Nagisa's birthday. The tree is so strange that every node of the tree has a value. The value of the *i*-th node is *v**i*. Now Furukawa Nagisa and Okazaki To...
5,177
Title: Magic Numbers Time Limit: None seconds Memory Limit: None megabytes Problem Description: A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not. You're ...
5,178
Title: Bear and Three Balls Time Limit: None seconds Memory Limit: None megabytes Problem Description: Limak is a little polar bear. He has *n* balls, the *i*-th ball has size *t**i*. Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make fri...
5,179
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are *n* schools numerated from 1 to *n*. One can travel betwee...
5,180
Title: Power Substring Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*. For every *a**i* you need to find a positive integer *k**i* such that the decimal notation of 2*k**i* contains the decimal notation of *a**i* as a substri...
5,181
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: На координатной прямой сидит *n* собачек, *i*-я собачка находится в точке *x**i*. Кроме того, на прямой есть *m* мисок с едой, для каждой известна её координата на прямой *u**j* и время *t**j*, через которое еда в миске остынет и ...
5,182
Title: Envy Time Limit: None seconds Memory Limit: None megabytes Problem Description: For a connected undirected weighted graph *G*, MST (minimum spanning tree) is a subgraph of *G* that contains all of *G*'s vertices, is a tree, and sum of its edges is minimum possible. You are given a graph *G*. If you run a MST...
5,183
Title: Jeff and Removing Periods Time Limit: None seconds Memory Limit: None megabytes Problem Description: Cosider a sequence, consisting of *n* integers: *a*1, *a*2, ..., *a**n*. Jeff can perform the following operation on sequence *a*: - take three integers *v*, *t*, *k* (1<=≤<=*v*,<=*t*<=≤<=*n*; 0<=≤<=*k*; *v*...
5,184
Title: Frodo and pillows Time Limit: None seconds Memory Limit: None megabytes Problem Description: *n* hobbits are planning to spend the night at Frodo's house. Frodo has *n* beds standing in a row and *m* pillows (*n*<=≤<=*m*). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as ma...
5,185
Title: Lunch Rush Time Limit: None seconds Memory Limit: None megabytes Problem Description: Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break. The Rabbits have a list of *n* restaurants to lunch in: the *i*-th re...
5,186
Title: Xor Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has four arrays: *a*, *b*, *k*, and *p*. Each array consists of *n* integers. Elements of all arrays are indexed starting from 1. Array *p* is a permutation of integers 1 to *n*. John invented a game for his friends and h...
5,187
Title: Alyona and mex Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alyona's mother wants to present an array of *n* non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she inspects *m* of its subarrays. Subarray is a s...
5,188
Title: Two Permutations Time Limit: None seconds Memory Limit: None megabytes Problem Description: Rubik is very keen on number permutations. A permutation *a* with length *n* is a sequence, consisting of *n* different numbers from 1 to *n*. Element number *i* (1<=≤<=*i*<=≤<=*n*) of this permutation will be denote...
5,189
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You have an array of positive integers *a*[1],<=*a*[2],<=...,<=*a*[*n*] and a set of bad prime numbers *b*1,<=*b*2,<=...,<=*b**m*. The prime numbers that do not occur in the set *b* are considered good. The beauty of array *a* is ...
5,190
Title: Unusual Product Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix. The dot product of two integer number vectors *x* and *y* of size *n* is the sum of the ...
5,191
Title: Anton and Permutation Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton likes permutations, especially he likes to permute their elements. Note that a permutation of *n* elements is a sequence of numbers {*a*1,<=*a*2,<=...,<=*a**n*}, in which every number from 1 to *n* appears e...
5,192
Title: Resort Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valera's finally decided to go on holiday! He packed up and headed for a ski resort. Valera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has *n*...
5,193
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of *n* distinct integers. And then they take turns to make the following moves. Du...
5,194
Title: Ancient Berland Circus Time Limit: 2 seconds Memory Limit: 64 megabytes Problem Description: Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and t...
5,195
Title: Cinema Time Limit: None seconds Memory Limit: None megabytes Problem Description: Overall there are *m* actors in Berland. Each actor has a personal identifier — an integer from 1 to *m* (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has *k* favori...
5,196
Title: Cubes Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day Petya got a set of wooden cubes as a present from his mom. Petya immediately built a whole city from these cubes. The base of the city is an *n*<=×<=*n* square, divided into unit squares. The square's sides are parallel ...
5,197
Title: Football Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into *n* teams and played several matches, two teams could not play against each other more ...
5,198
Title: Lucky Mask Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Pe...
5,199