Function

2020 VietMX 0

Serega and Fedor play with functions. One day they came across a very interesting function. It looks like that: f(1, j) = a[j], 1 ≤ j ≤ n. f(i, j) = min(f(i - 1, j), f(i - 1, j - 1)) + a[j], 2 ≤ i ≤ n, i ≤ j ≤ n. Here a is an integer array […]

Golden System

2020 VietMX 0

Piegirl got bored with binary, decimal and other integer based counting systems. Recently she discovered some interesting properties about number , in particular that q 2 = q + 1, and she […]

Elections

2020 VietMX 0

You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in […]

Distributed Join

2020 VietMX 0

Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic. Suppose she wants to join two tables, A and B. Each […]

No to Palindromes

2020 VietMX 30

Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn’t contain any palindrome contiguous substring of length […]

Bingo!

2020 VietMX 0

The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on […]

Substitutes in Number

2020 VietMX 1

Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type ” d i → t i“, that means “replace […]

Restore Cube

2020 VietMX 0

Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay […]

Cheap Travel

2020 VietMX 0

Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a […]

Wonder Room

2020 VietMX 0

The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a a × b square meter wonder room. […]

Number of Ways

2020 VietMX 0

You’ve got array a[1], a[2], …, a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the […]

Increase Sequence

2020 VietMX 0

Peter has a sequence of integers a 1, a 2, …, a n. Peter wants all numbers in the sequence to equal h. He can perform the operation of “adding one on the […]

Information Graph

2020 VietMX 0

There are n employees working in company “X” (let’s number them from 1 to n for convenience). Initially the employees didn’t have any relationships among each other. On each […]

Keyboard

2020 VietMX 0

Our good friend Mole is trying to code a big message. He is typing on an unusual keyboard with characters arranged in following way: qwertyuiopasdfghjkl;zxcvbnm,./ […]