QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21280. Ландшафтный дизайн

Statistics

Farmer John строит красивый сад и должен переместить много земли.

Сад — ряд из $N$ клумб ($1 \le N \le 100$). В клумбе $i$ сначала $A_{i}$ единиц земли, а нужно $B_{i}$. Все $A_{i}$ и $B_{i}$ — целые из $0..10$.

Можно купить единицу земли и поместить в любую клумбу за $X$, удалить и вывезти единицу из любой за $Y$, либо переместить единицу из $i$ в $j$ за $Z$ раз $|i-j|$. Найдите минимальную общую стоимость.

Входные данные

  • Строка 1: целые через пробел $N$, $X$, $Y$, $Z$; $0 \le X, Y, Z \le 1000$.
  • Строки $2..1+N$: строка $i+1$ содержит $A_{i}$ и $B_{i}$ через пробел.

Выходные данные

  • Строка 1: целое — минимальная стоимость проекта.

Примеры

Входные данные 1

4 100 200 1
1 4
2 3
3 2
4 0

Выходные данные 1

210

Примечание

Четыре клумбы в ряду содержат 1, 2, 3, 4 единицы; нужны 4, 3, 2, 0. Добавление, удаление и перевозка стоят 100, 200, 1.

Единицу нужно удалить из клумбы 4 за 200. Остальное переместить за 10: три единицы из 4 в 1 и одну из 3 в 2.

Автор задачи: Brian Dean, 2012

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.