Problem A. Gorn

Input file:input.txt   Time limit:1 sec
Output file:output.txt   Memory limit:256 Mb
Maximum points:100  

Statement

Wilhelm plays Gorn game in virtual reality, fighting against N gladiators on the arena. He has a bow and an infinite number of arrows and never misses an enemy with a shot.

When Wilhelm hits an enemy gladiator for the first time, he inflicts D points of damage, so gladiator loses D hit points. Every following hit on the same gladiator increases damage by K points due to weakening of the gladiator's armor. When hitting a new gladiator, damage again starts with D and increases after each hit. Gladiator dies when his hit points become zero or negative.

What is the minimum number of arrows Wilhelm must spend to kill all gladiators?

Constraints

1 ≤ N ≤ 104

1 ≤ D≤ 105

1 ≤ K ≤ 103

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
4 1 1
1 2 3 4
8

Problem B. Автономная охрана

Author:М. Спорышев, А. Кленин   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  
Maximum points:100  

Statement

Young programmer Vasya tinkered with robots, and decided to create a new startup Delta Security with the goal of producing robot guardian to replace human guards.

As a first step, he considered a single wall and two patrolling robots moving back and forth along it.

First robot patrols a segment from L1 to R1 meters. Second robot patrols a segment from L2 to R2 meters.

At the start, each robot is located at the leftmost point of its segment and is facing to the right.

Each second, every robot checks whether it has reached the edge of its segment. In that case, robot reverses its direction. Then, robot moves exactly 1 meter in its current direction. Robots continue to patrol indefinitely. All robots move simultaneously.

You task is to determine maximum possible distance between two robots.

Robots could be located in the same position on the wall. This case doesn't affect their movements.

Input file format

Input file contains integers L1 R1 L2 R2.

Output file format

Output file must contain a single integer — maximum distance between robots.

Constraints

0 ≤ L1 < L2 ≤ 109, 0 ≤ R1 < R2 ≤ 109

L1 < R1, L2 < R2

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
5 10
7 12
2
2
1 5
8 9
7

Задача C. RollerBall-2

Автор:Mikhail Babich   Ограничение времени:30 сек
Входной файл:input.txt   Ограничение памяти:256 Мб
Выходной файл:output.txt  
Максимальный балл:100  

Условие

Юному программисту Васе очень нравится игра RollerBall. Он решил посоревноваться с другими игроками в прохождении лабиринта на скорость. Цель игры - за минимальное количество шагов достичь монеты мячом в лабиринте. Для того, чтобы взять монету, её границы нужно пересечь мячом, которым Вася может управлять. У мяча есть энергия, которая расходуется на каждом шаге.

Вася очень хочет победить и для этого решил написать программу, которая бы управляла мячом и сама собрала бы монету в лабиринте. Проект, который написал Вася, уже содержит игру и умеет вводить и выводить файлы нужных форматов. Вам необходимо реализовать класс AutoBallControl для управления мячом.

Задача будет проверятся на одном тесте, содержащимся в репозитории проекта. Вам необходимо собрать монету за минимальное количество шагов, используя предоставленный интерфейс для движения мяча. Программе запрещено модифицировать сцену.

Формат выходного файла

Файл с решением должен содержать реализацию класса AutoBallControl.


0.056s 0.007s 11