Two-gram

2020 VietMX 0

Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, “AZ”, “AA”, “ZA” — three distinct two-grams. You are […]

Hiking

2020 VietMX 0

A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from […]

One-Based Arithmetic

2020 VietMX 0

Prof. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent […]

Berland Federalization

2020 VietMX 4

Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is […]

Three Problems

2020 VietMX 0

Polycarp is choosing three problems for creating a programming test. Totally he has $n$ problems in his list. The complexity of the $i$-th problem equals […]

Ice Cream

2020 VietMX 0

Summer in Berland lasts $n$ days, the price of one portion of ice cream on the $i$-th day is $c_i$. Over the summer, Tanya wants […]

Teams

2020 VietMX 0

There are $n$ table bowling players, the rating of the $i$-th player equals $r_i$. Compose a maximum number of teams in a such way that: […]

Double Permutation Inc

2020 VietMX 0

Polycarp recently became an employee of the company “Double Permutation Inc.” Now he is a fan of permutations and is looking for them everywhere! A […]

King’s Path

2020 VietMX 0

There are $n$ cities and $n-1$ two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to […]

Unusual Graph

2020 VietMX 0

Ivan on his birthday was presented with array of non-negative integers $a_1, a_2, \ldots, a_n$. He immediately noted that all $a_i$ satisfy the condition $0 […]

Paint the Numbers

2020 VietMX 0

You are given a sequence of integers $a_1, a_2, \dots, a_n$. You need to paint elements in colors, so that: If we consider any color, […]

Koala and Lights

2020 VietMX 0

It is a holiday season, and Koala is decorating his house with cool lights! He owns $n$ lights, all of which flash periodically. After taking […]

Paint the Digits

2020 VietMX 85

You are given a sequence of $n$ digits $d_1d_2 \dots d_{n}$. You need to paint all the digits in two colors so that: each digit […]

Cow and Snacks

2020 VietMX 0

The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are […]

Koala and Notebook

2020 VietMX 0

Koala Land consists of $m$ bidirectional roads connecting $n$ cities. The roads are numbered from $1$ to $m$ by order in input. It is guaranteed, […]