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 |
|---|---|---|---|---|---|
E. Numbers Exchangetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEugeny has n cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd ... | Input6 25 6 7 9 4 5 | Output15 6 7 9 4 2 | 1 second | 256 megabytes | ['greedy', 'implementation', 'math', '*1900'] |
D. Green and Black Teatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInnokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.Innokentiy doesn... | Input5 1 3 2 | OutputGBGBG | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1500'] |
C. Tramtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear mot... | Input4 2 43 41 1 | Output8 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*1600'] |
B. Decodingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter ... | Input5logva | Outputvolga | 1 second | 256 megabytes | ['implementation', 'strings', '*900'] |
A. Compotetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 appl... | Input257 | Output7 | 1 second | 256 megabytes | ['implementation', 'math', '*800'] |
B. Hongcow Solves A Puzzletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHongcow likes solving puzzles.One day, Hongcow finds two identical puzzle pieces, with the instructions "make a rectangle" next to them. The pieces can be described by an n by m grid of charac... | Input2 3XXXXXX | OutputYES | 2 seconds | 256 megabytes | ['implementation', '*1400'] |
A. Hongcow Learns the Cyclic Shifttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.Hongcow has de... | Inputabcd | Output4 | 2 seconds | 256 megabytes | ['implementation', 'strings', '*900'] |
E. Hongcow Masters the Cyclic Shifttime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHongcow's teacher heard that Hongcow had learned about the cyclic shift, and decided to set the following problem for him.You are given a list of n strings s1, s2, ..., sn contained i... | Input4aabbbba | Output7 | 5 seconds | 256 megabytes | ['strings', 'two pointers', '*3200'] |
D. Hongcow Draws a Circletime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHongcow really likes the color red. Hongcow doesn't like the color blue.Hongcow is standing in an infinite field where there are n red points and m blue points.Hongcow wants to draw a circle in... | Input2 52 33 41 11 44 24 72 5 | Output3.5355338827 | 6 seconds | 256 megabytes | ['geometry', '*3200'] |
C. Hongcow Buys a Deck of Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Hongcow goes to the store and sees a brand new deck of n special cards. Each individual card is either red or blue. He decides he wants to buy them immediately. To do this, he ne... | Input3R 0 1B 1 0R 1 1 | Output4 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', '*2400'] |
B. Hongcow's Gametime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem. In the interaction section below you will see the information about flushing the output.In this problem, you will be playing a game with Hongcow. How lucky of you!Hongco... | Input30 0 02 7 00 0 43 0 80 5 4 | Output31 2 31321 21211-12 5 4 | 3 seconds | 256 megabytes | ['bitmasks', 'divide and conquer', 'interactive', '*1900'] |
A. Hongcow Builds A Nationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputHongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.The world can be modeled as an undirected graph with n ... | Input4 1 21 31 2 | Output2 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*1500'] |
E. Vladik and cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not exceeding 8 written on... | Input31 1 1 | Output1 | 2 seconds | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'dp', '*2200'] |
D. Chloe and pleasant prizestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGenerous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decora... | Input80 5 -1 4 3 2 6 51 22 42 51 33 66 76 8 | Output25 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*1800'] |
C. Vladik and fractionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct positive fractions in form... | Input3 | Output2 7 42 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'math', 'number theory', '*1500'] |
B. Chloe and the sequence time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputChloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.Let's consider... | Input3 2 | Output2 | 1 second | 256 megabytes | ['binary search', 'bitmasks', 'constructive algorithms', 'implementation', '*1200'] |
A. Vladik and flightstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is to find the cheapest ... | Input4 1 41010 | Output1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*1200'] |
B. Arpa’s obvious problem and Mehrdad’s terrible solutiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are some beautiful girls in Arpa’s land as mentioned before.Once Arpa came up with an obvious problem:Given an array and a number x, count the number of pai... | Input2 31 2 | Output1 | 1 second | 256 megabytes | ['brute force', 'math', 'number theory', '*1500'] |
A. Arpa’s hard exam and Mehrdad’s naive cheattime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam h... | Input1 | Output8 | 1 second | 256 megabytes | ['implementation', 'math', 'number theory', '*1000'] |
E. Arpa’s abnormal DNA and Mehrdad’s deep interesttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAll of us know that girls in Arpa’s land are... ok, you’ve got the idea :DAnyone knows that Arpa isn't a normal man, he is ... well, sorry, I can't explain it more. Meh... | Inputabc d 40 3 2 0 00 3 1 0 01 2 1 0 00 1 3 2 2 | Output2 3 2 -1 | 2 seconds | 256 megabytes | ['data structures', 'string suffix structures', '*3400'] |
D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh pathstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputJust 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 vertic... | Input41 s2 a3 s | Output3 1 1 0 | 3 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'trees', '*2900'] |
C. Arpa’s overnight party and Mehrdad’s silent enteringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote that girls in Arpa’s land are really attractive.Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs o... | Input31 42 53 6 | Output1 22 11 2 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2600'] |
B. Arpa's weak amphitheater and Mehrdad's valuable Hosestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJust to remind, girls in Arpa's land are really nice.Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some bea... | Input3 1 53 2 52 4 21 2 | Output6 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'dsu', '*1600'] |
A. Arpa's loud Owf and Mehrdad's evil plantime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you have noticed, there are lovely girls in Arpa’s land.People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the... | Input42 3 1 4 | Output3 | 1 second | 256 megabytes | ['dfs and similar', 'math', '*1600'] |
B. Alyona and flowerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.Let's define ... | Input5 41 -2 1 3 -41 24 53 41 4 | Output7 | 2 seconds | 256 megabytes | ['constructive algorithms', '*1200'] |
A. Alyona and copybookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook... | Input1 1 3 4 | Output3 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1300'] |
E. Gosha is huntingtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGosha is hunting. His goal is to catch as many Pokemons as possible. Gosha has a Poke Balls and b Ultra Balls. There are n Pokemons. They are numbered 1 through n. Gosha knows that if he throws a Pok... | Input3 2 21.000 0.000 0.5000.000 1.000 0.500 | Output2.75 | 5 seconds | 256 megabytes | ['brute force', 'data structures', 'dp', 'flows', 'math', 'probabilities', 'sortings', '*3000'] |
D. Recover a functional graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFunctional graph is a directed graph in which all vertices have outdegree equal to 1. Loops are allowed.Some vertices of a functional graph lay on a cycle. From the others we can come to a ... | Input30 30 3? ? | Output2 3 1 | 2 seconds | 256 megabytes | ['graph matchings', '*3400'] |
C. Alyona and towerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next... | Input55 5 5 5 531 3 22 2 14 4 1 | Output245 | 2 seconds | 256 megabytes | ['data structures', '*2500'] |
B. Alyona and a treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to... | Input52 5 1 4 61 71 13 53 6 | Output1 0 1 0 0 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dfs and similar', 'graphs', 'trees', '*1900'] |
A. Alyona and mextime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlyona'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. Su... | Input5 31 32 54 5 | Output21 0 2 1 0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*1700'] |
F. Dirty platestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter one of celebrations there is a stack of dirty plates in Nikita's kitchen. Nikita has to wash them and put into a dryer. In dryer, the plates should be also placed in a stack also, and the plates si... | Input6 2 32 3 6 4 1 5 | OutputYES81 21 12 11 21 12 12 12 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*3300'] |
E. Tanya is 5!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTanya is now five so all her friends gathered together to celebrate her birthday. There are n children on the celebration, including Tanya.The celebration is close to its end, and the last planned attract... | Input2 2 1003 72 1 3 2 12 1 3 2 1 | Output41081 1 0 12 2 0 11 1 1 12 1 1 12 1 2 11 1 2 11 2 3 12 1 3 1 | 2 seconds | 256 megabytes | ['graph matchings', 'graphs', 'greedy', 'schedules', '*3300'] |
E. Chess Championshiptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOstap is preparing to play chess again and this time he is about to prepare. Thus, he was closely monitoring one recent chess tournament. There were m players participating and each pair of players... | Input5 58 6 4 2 0 | OutputyesXWWWWLXWWWLLXWWLLLXWLLLLX | 2 seconds | 256 megabytes | ['constructive algorithms', 'flows', 'greedy', 'math', '*2900'] |
D. Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOstap Bender is worried that people started to forget that he is the Great Combinator. Now he wants to show them his skills in combinatorics. Now he studies the permutations of length n. He has a list of... | Input2 31 11 22 2 | OutputNOYESNO | 2 seconds | 256 megabytes | ['math', 'matrices', '*2800'] |
E. Ostap and Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOstap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to pa... | Input2 01 2 | Output1 | 2 seconds | 256 megabytes | ['dp', 'trees', '*2500'] |
D. Taxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor... | Input4 | Output2 | 2 seconds | 256 megabytes | ['math', 'number theory', '*1600'] |
C. Tennis Championshiptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFamous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules f... | Input2 | Output1 | 2 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', 'greedy', 'math', '*1600'] |
B. Urbanizationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLocal authorities have heard a lot about combinatorial abilities of Ostap Bender so they decided to ask his help in the question of urbanization. There are n people who plan to move to the cities. The we... | Input2 1 11 5 | Output6.00000000 | 2 seconds | 256 megabytes | ['greedy', 'number theory', 'sortings', '*1100'] |
A. Ostap and Grasshoppertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some c... | Input5 2#G#T# | OutputYES | 2 seconds | 256 megabytes | ['implementation', 'strings', '*800'] |
F. Anton and Schooltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton goes to school, his favorite lessons are arraystudying. He usually solves all the tasks pretty fast, but this time the teacher gave him a complicated one: given two arrays b and c of length n, ... | Input46 8 4 416 22 10 10 | Output3 5 1 1 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'implementation', 'math', '*2500'] |
E. Anton and Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph.There are n vertices in the tree, each of them is painted black or white. Anton doesn't like ... | Input110 0 0 1 1 0 1 0 0 1 11 21 32 42 55 65 73 83 93 109 11 | Output2 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'trees', '*2100'] |
D. Anton and Chesstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite... | Input24 2R 1 1B 1 5 | OutputYES | 4 seconds | 256 megabytes | ['implementation', '*1700'] |
C. Anton and Making Potionstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions.Anton has a special kettle, that can prepare... | Input20 3 210 992 4 320 10 404 1510 80 | Output20 | 4 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', 'two pointers', '*1600'] |
B. Anton and Digitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6.Anton's favorite integers are 32 and 256. He decided to compose this integers from d... | Input5 1 3 4 | Output800 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', 'math', '*800'] |
A. Anton and Daniktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton likes to play chess, and so does his friend Danik.Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.Now Anto... | Input6ADAAAA | OutputAnton | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
F. Drivers Dissatisfactiontime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn one kingdom there are n cities and m two-way roads. Each road connects a pair of cities, and for each road we know the level of drivers dissatisfaction — the value wi.For each road we know ... | Input6 91 3 1 1 3 1 2 2 24 1 4 2 2 5 3 1 61 21 32 32 42 53 53 64 55 67 | Output01 13 16 17 28 -5 | 4 seconds | 256 megabytes | ['data structures', 'dsu', 'graphs', 'trees', '*2200'] |
E. Sleep in Classtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was... | Input3UUD | Output5 6 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'math', 'two pointers', '*2400'] |
D. Kostya the Sculptortime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to pre... | Input65 5 53 2 41 4 12 1 33 2 43 3 4 | Output11 | 3 seconds | 256 megabytes | ['data structures', 'hashing', '*1600'] |
C. Epidemic in Monstropolistime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.Soon, monsters became hungry an... | Input61 2 2 2 1 225 5 | OutputYES2 L1 R4 L3 L | 1 second | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', 'two pointers', '*1800'] |
B. Paradetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVery soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from whi... | Input35 68 910 3 | Output3 | 1 second | 256 megabytes | ['math', '*1100'] |
A. Grasshopper And the Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able t... | InputABABBBACFEYUKOTT | Output4 | 1 second | 256 megabytes | ['implementation', '*1000'] |
F. Tourist Reformtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland is a tourist country! At least, it can become such — the government of Berland is confident about this. There are n cities in Berland, some pairs of which are connected by two-ways roads. Each ... | Input7 94 32 67 14 17 33 57 46 52 5 | Output44 36 27 11 43 75 37 45 62 5 | 4 seconds | 256 megabytes | ['dfs and similar', 'graphs', '*2300'] |
E. Socketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe ICM ACPC World Finals is coming! Unfortunately, the organizers of the competition were so busy preparing tasks that totally missed an important technical point — the organization of electricity supplement... | Input2 21 12 2 | Output2 21 11 2 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*2100'] |
D. Examstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.About every day we know exam for which one of m subjects can be passed on that day... | Input7 20 1 0 2 1 0 22 1 | Output5 | 1 second | 256 megabytes | ['binary search', 'greedy', 'sortings', '*1700'] |
C. Sanatoriumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation! Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (... | Input3 2 1 | Output1 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'implementation', 'math', '*1200'] |
B. Cormen — The Best Friend Of a Mantime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. Empirically Polycarp learned that the... | Input3 52 0 1 | Output42 3 2 | 1 second | 256 megabytes | ['dp', 'greedy', '*1000'] |
A. Buy a Shoveltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in th... | Input117 3 | Output9 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'math', '*800'] |
F. Video Cardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new ... | Input43 2 15 9 | Output27 | 1 second | 256 megabytes | ['brute force', 'data structures', 'implementation', 'math', 'number theory', '*1900'] |
E. Funny Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They... | Input32 4 8 | Output14 | 1 second | 256 megabytes | ['dp', 'games', '*2200'] |
D. 80-th Level Archeologytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArcheologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, eac... | Input4 32 3 21 13 2 3 14 2 3 1 2 | Output1 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'greedy', 'sortings', '*2200'] |
C. Sockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. Ten minut... | Input3 2 31 2 31 22 3 | Output2 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'greedy', '*1600'] |
B. Coupons and Discountstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's ... | Input41 2 1 2 | OutputYES | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1100'] |
A. Night at the Museumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGrigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.Embosser is... | Inputzeus | Output18 | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
L. Expression Queriestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA simplified arithmetic expression (SAE) is an arithmetic expression defined by the following grammar: <SAE> ::= <Number> | <SAE>+<SAE> | <SAE>*<SAE> | (<SAE>) <Number> ::= <Digit> | <Digit><Numb... | Input((1+2)*3+101*2)68 141 62 1011 145 54 5 | Output205-11022-1 | 4 seconds | 512 megabytes | ['data structures', '*3200'] |
K. Roads Orientation Problemtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBerland consists of n cities and m bidirectional roads connecting pairs of cities. There is no road connecting a city to itself, and between any pair of cities there is no more than one road... | Input24 4 1 21 22 33 44 13 2 1 33 12 3 | OutputYes1 23 24 31 4No | 5 seconds | 512 megabytes | ['graphs', '*3200'] |
J. Bottlestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≤ bi).Nick has decided to pour all remaining soda into minimal ... | Input43 3 4 34 7 6 5 | Output2 6 | 2 seconds | 512 megabytes | ['dp', '*1900'] |
I. Olympiad in Programming and Sportstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n students at Berland State University. Every student has two skills, each measured as a number: ai — the programming skill and bi — the sports skill.It is announced that ... | Input5 2 21 3 4 5 25 3 2 1 4 | Output183 4 1 5 | 2 seconds | 512 megabytes | ['dp', 'flows', 'graphs', 'greedy', '*2000'] |
H. Delete Themtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolycarp is a beginner programmer. He is studying how to use a command line.Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to ru... | Input3 2abaccd1 2 | OutputYesa? | 2 seconds | 512 megabytes | ['constructive algorithms', 'implementation', '*1300'] |
G. Car Repair Shoptime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time.Polycarp is ... | Input39 27 32 4 | Output9 101 34 7 | 2 seconds | 512 megabytes | ['implementation', '*1600'] |
F. Ber Patiotime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolycarp is a regular customer at the restaurant "Ber Patio". He likes having lunches there."Ber Patio" has special discount program for regular customers. A customer can collect bonuses and partially cover... | Input3 2112 75 52 | Output1102 5 22 | 3 seconds | 512 megabytes | ['*3100'] |
E. Award Ceremonytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAll-Berland programming contest comes to an end. In total, n teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, r... | Input417 -1452 -51 526 0 | Output4 | 2 seconds | 512 megabytes | ['greedy', 'implementation', '*2200'] |
D. Running Over The Bridgestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolycarp is playing a game called "Running Over The Bridges". In this game he has to run over n bridges from the left to the right. Bridges are arranged one after the other, so the i-th bridg... | Input1 3710 | Output20 3 | 2 seconds | 512 megabytes | ['greedy', 'implementation', 'math', '*2200'] |
C. Bulmarttime limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA new trade empire is rising in Berland. Bulmart, an emerging trade giant, decided to dominate the market of ... shovels! And now almost every city in Berland has a Bulmart store, and some cities even have ... | Input6 44 25 41 23 224 1 23 2 361 2 62 3 73 1 24 3 85 2 56 1 10 | Output2-1223-1 | 1.5 seconds | 512 megabytes | ['binary search', 'dfs and similar', '*2100'] |
B. Minimum and Maximumtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem. You have to use flush operation right after printing each line. For example, in C++ you should use function fflush(stdout), in Java — System.out.flush(), in Pascal ... | Input22 > 3 = = | Output ? 1 2 ! 2 1 ? 3 1 ? 2 1 ! 2 3 | 4 seconds | 512 megabytes | ['constructive algorithms', 'interactive', '*1800'] |
A. Toda 2time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA group of n friends enjoys playing popular video game Toda 2. There is a rating system describing skill level of each player, initially the rating of the i-th friend is ri.The friends decided to take part in ... | Input54 5 1 7 4 | Output180101000011010101001000011110000001111000 | 2 seconds | 512 megabytes | ['greedy', 'implementation', '*1800'] |
F. Financiers Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis problem has unusual memory constraint.At evening, Igor and Zhenya the financiers became boring, so they decided to play a game. They prepared n papers with the income of some company for some tim... | Input31 3 1 | Output4 | 2 seconds | 512 megabytes | ['dp', '*2500'] |
E. Subordinatestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.There was a request... | Input3 22 0 2 | Output1 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'graphs', 'greedy', 'sortings', '*1900'] |
D. Sea Battletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGalya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the sh... | Input5 1 2 100100 | Output24 2 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*1700'] |
C. Road to Cinematime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Le... | Input3 1 8 1010 85 711 93 | Output10 | 1 second | 256 megabytes | ['binary search', 'greedy', 'sortings', '*1700'] |
B. Spotlightstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTheater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.You... | Input2 40 1 0 01 0 1 0 | Output9 | 1 second | 256 megabytes | ['dp', 'implementation', '*1200'] |
A. Interview with Olegtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp 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.T... | Input7aogogob | Outputa***b | 1 second | 256 megabytes | ['implementation', 'strings', '*900'] |
F. Polycarp's problemstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is an experienced participant in Codehorses programming contests. Now he wants to become a problemsetter.He sent to the coordinator a set of n problems. Each problem has it's quality, the... | Input6 38 -5 -4 1 -7 40 7 3 | Output201 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', '*2300'] |
E. Games on a CDtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSeveral years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise... | Input3 1abc4bacd | OutputYES2 1 3 | 4 seconds | 512 megabytes | ['data structures', 'hashing', 'string suffix structures', 'strings', '*2300'] |
D. T-shirts Distributiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in incre... | Input0 1 0 1 1 03XLS,MXL,XXL | OutputYESXLMXXL | 1 second | 256 megabytes | ['constructive algorithms', 'flows', 'greedy', '*1800'] |
C. Guess the Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flu... | Input5 9 7 9 11 6 | Output ? 1 5 ? 2 3 ? 4 1 ? 5 2 ? 3 4 ! 4 6 1 5 5 | 1 second | 256 megabytes | ['constructive algorithms', 'interactive', 'math', '*1400'] |
B. Bill Total Valuetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row with... | Inputchipsy48.32televizor12.390 | Output12.438.32 | 1 second | 256 megabytes | ['expression parsing', 'implementation', 'strings', '*1600'] |
A. Transformation: from A to Btime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2·x);... | Input2 162 | OutputYES52 4 8 81 162 | 1 second | 256 megabytes | ['brute force', 'dfs and similar', 'math', '*1000'] |
G. Messages on a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are well-known for sending messages to each other. This time you have a rooted tree with Bob standing in the root node and copies of Alice standing in each of the other vertices. The ... | Input6 30 1 2 3 2 54 66 95 11 | Output14 13 11 | 2 seconds | 256 megabytes | ['*3300'] |
F. Family Photostime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, t... | Input212 3 4 71 15 9 1 | Output1 | 2 seconds | 256 megabytes | ['games', 'greedy', '*2900'] |
E. Too Much Moneytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlfred wants to buy a toy moose that costs c dollars. The store doesn’t give change, so he must give the store exactly c dollars, no more and no less. He has n coins. To make c dollars from his coins, ... | Input123534 | Output5 | 2 seconds | 256 megabytes | ['brute force', 'greedy', '*2600'] |
D. Contest Balloonstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they h... | Input820 100032 3740 100045 5016 1616 1614 10002 1000 | Output3 | 3 seconds | 256 megabytes | ['data structures', 'greedy', '*1800'] |
C. Hidden Wordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same lett... | InputABCDEFGHIJKLMNOPQRSGTUVWXYZ | OutputYXWVUTGHIJKLMZABCDEFSRQPON | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'strings', '*1600'] |
B. Food on the Planetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to '... | Input1f | Output1 | 2 seconds | 256 megabytes | ['implementation', 'math', '*1200'] |
A. Jumping Balltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are... | Input4<<>< | Output2 | 2 seconds | 256 megabytes | ['implementation', '*1000'] |
G. Xor-matic Number of the Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.Let's call a triple (u, v, s) interesting, if... | Input4 41 2 11 3 22 3 33 4 1 | Output12 | 2 seconds | 256 megabytes | ['bitmasks', 'graphs', 'math', 'number theory', 'trees', '*2600'] |
F. Uniformly Branched Treestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is a connected graph without cycles.Two trees, consisting of n vertices each, are called isomorphic if there exists a permutation p: {1, ..., n} → {1, ..., n} such that the edge (u, v) ... | Input5 2 433416647 | Output1 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'trees', '*2700'] |
E. Goods transportationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities located along the one-way road. Cities are numbered from 1 to n in the direction of the road.The i-th city had produced pi units of goods. No more than si units of goods can be... | Input3 01 2 33 2 1 | Output4 | 2 seconds | 256 megabytes | ['dp', 'flows', 'greedy', '*2900'] |
D. Dense Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of lowercase English letters, and the integer m.One should choose some symbols from the given string so that any contiguous subsegment of length m has at least o... | Input3cbabc | Outputa | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'strings', '*1900'] |
C. Ray Tracingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (xi, yi). All sensors are located at distinct points strictly inside the rectangle. Opposite c... | Input3 3 41 11 22 12 2 | Output1-1-12 | 2 seconds | 256 megabytes | ['greedy', 'hashing', 'implementation', 'math', 'number theory', 'sortings', '*1800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.