Editorial of Educational Codeforces Round 6

Revision en2, by Edvard, 2016-01-21 23:50:53

620A - Робот профессора GukiZ

Easy to see that the answer is max(|x1 - x2|, |y1 - y2|).

С++ solution

Complexity: O(1).

620B - Калькулятор дедушки Довлета

Let's simply iterate over all the values from a to b and add to the answer the number of segments of the current value x. To count the number of segments we should iterate over all the digits of the number x and add to the answer the number of segments of the current digit d. These values can be calculated by the image from the problem statement and stored in some array in code.

C++ solution

Complexity: O((b - a)logb).

620C - Жемчужинки

Let's solve the problem greedily. Let's make the first segment by adding elements until the segment will be good. After that let's make the second segment in the same way and so on. If we couldn't make any good segment then the answer is  - 1. Otherwise let's add all uncovered elements at the end to the last segment. Easy to prove that our construction is optimal: consider the first two segments of the optimal answer, obviously we can extend the second segment until the first segment will be equal to the first segment in our construction.

C++ solution

Complexity: O(nlogn).

Tags education round 6, editorial

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English Edvard 2016-01-22 02:01:59 2211
en4 English Edvard 2016-01-22 00:51:22 646
en3 English Edvard 2016-01-21 23:59:52 785
ru8 Russian Edvard 2016-01-21 23:58:33 6 Мелкая правка: '2 \cdot (b[i] + b[j])$ и обнов' -> '2 \cdot (b_i + b_j)$ и обнов'
ru7 Russian Edvard 2016-01-21 23:52:05 3 Мелкая правка: 'б (за $O(n^2)$). Тепер' -> 'б (за $O(nm)$). Тепер'
en2 English Edvard 2016-01-21 23:50:53 647
ru6 Russian Edvard 2016-01-21 23:44:22 2 Мелкая правка: 'новый хорощий подотре' -> 'новый хороший подотре'
en1 English Edvard 2016-01-21 23:34:37 694 Initial revision for English translation
ru5 Russian Edvard 2016-01-21 23:33:29 2 Мелкая правка: 'гментов, наобходимой ' -> 'гментов, необходимой '
ru4 Russian Edvard 2016-01-21 23:29:31 2 Мелкая правка: 'x(|x_1-x_2, y_1-y_2|)$' -> 'x(|x_1-x_2|, |y_1-y_2|)$'
ru3 Russian Edvard 2016-01-21 23:25:46 1987 Мелкая правка: 'но делать делать во' -
ru2 Russian Edvard 2016-01-21 22:22:44 615
ru1 Russian Edvard 2016-01-21 20:03:21 2438 Первая редакция (опубликовано)