”Ґа¬Ґа „¦® бва®Ёв б ¤ Ё Ґ¬г вॡгҐвбп ЇҐаҐ¬ҐбвЁвм ¬®Ј® ¤са .
‘ ¤ б®бв®Ёв Ё§ Ї®б«Ґ¤®ў ⥫м®бвЁ Ё§ \(N\) Є«г¬Ў (\(1 \leq N \leq 100,000\)),
ѓ¤Ґ Є«г¬Ў \(i\) Ё§ з «м® б®¤Ґа¦Ёв \(A_i\) Ґ¤ЁЁж ¤са . ”„ е®зҐв ८࣠Ё§®ў вм б ¤ в Є, зв®Ўл Є ¦¤ п Є«г¬Ў бв « ᮤҐа¦ вм \(B_i\) Ґ¤ЁЁж ¤са . \(A_i\) Ё \(B_i\) - жҐ«лҐ зЁб« ў ЁвҐаў «Ґ \(0 \ldots 10\).
„«п Ё§¬ҐҐЁп « ¤и дв ”„ Ё¬ҐҐв ҐбЄ®«мЄ® ў аЁ в®ў: ® ¬®¦Ґв ЄгЇЁвм ®¤г Ґ¤ЁЁжг ¤са Ё Ї®«®¦Ёвм Ґс «оЎго Є«г¬Ўг § \(X\) Ґ¤ЁЁж ¤ҐҐЈ. Ћ ¬®¦Ґв бпвм ®¤г Ґ¤ЁЁжг ¤са б «оЎ®© Є«г¬Ўл Ё Їа®¤ вм Ґс § \(Y\) Ґ¤ЁЁж ¤ҐҐЈ. Ћ в Є¦Ґ ¬®¦Ґв
ЏҐаҐ¬ҐбвЁвм ®¤г Ґ¤ЁЁжг ¤са б Є«г¬Ўл \(i\) Є«г¬Ўг \(j\) § \(Z\) times \(|i-j|\).
‚лзЁб«ЁвҐ ¬ЁЁ¬ «мго бв®Ё¬®бвм, § Є®в®аго ”„ ¬®¦Ґв ўлЇ®«Ёвм бў®© Їа®ҐЄв.
”ЋђЊЂ’ ‚‚Ћ„Ђ (д ©« landscape.in):
ЏҐаў п бва®Є ўў®¤ ᮤҐа¦Ёв \(N\), \(X\), \(Y\), \(Z\) (\(0 \leq X, Y \le 10^8; 0 \le Z \leq 1000\)).
‘ва®Є \(i+1\) ᮤҐа¦Ёв жҐ«лҐ зЁб« \(A_i\) Ё \(B_i\).
”ЋђЊЂ’ ‚›‚Ћ„Ђ (д ©« landscape.out):
‚뢥¤ЁвҐ ¬ЁЁ¬ «мго б㬬 аго бв®Ё¬®бвм Їа®ўҐ¤ҐЁп а Ў®в.
Џђ€Њ…ђ ‚‚Ћ„Ђ:
4 100 200 1
1 4
2 3
3 2
4 0
Џђ€Њ…ђ ‚›‚Ћ„Ђ:
210
‡ ¬ҐвЁ¬ зв® в Є п § ¤ з ¤ ў « бм ў ®¤®¬ Ё§ ЇаҐ¦Ёе USACO-Є®вҐбв®ў га®ўҐ Silver. Ћ¤ Є® ᥩз б бгйҐб⢥® 㬥м襮 ўаҐ¬п вҐбв.
Ђўв®а: Brian Dean
Farmer John is building a nicely-landscaped garden, and needs to move a large
amount of dirt in the process.
The garden consists of a sequence of \(N\) flowerbeds (\(1 \leq N \leq 100,000\)),
where flowerbed \(i\) initially contains \(A_i\) units of dirt. Farmer John would
like to re-landscape the garden so that each flowerbed \(i\) instead contains
\(B_i\) units of dirt. The \(A_i\)'s and \(B_i\)'s are all integers in the range
\(0 \ldots 10\).
To landscape the garden, Farmer John has several options: he can purchase one
unit of dirt and place it in a flowerbed of his choice for \(X\) units of money.
He can remove one unit of dirt from a flowerbed of his choice and have it
shipped away for \(Y\) units of money. He can also transport one unit of dirt
from flowerbed \(i\) to flowerbed \(j\) at a cost of \(Z\) times \(|i-j|\). Please
compute the minimum total cost for Farmer John to complete his landscaping
project.
Формат входных данных:
The first line of input contains \(N\), \(X\), \(Y\), and \(Z\)
(\(0 \leq X, Y \le 10^8; 0 \le Z \leq 1000\)). Line \(i+1\) contains the integers \(A_i\) and \(B_i\).
Формат выходных данных:
Please print the minimum total cost FJ needs to spend on landscaping.
Примеры
| № | Входные данные | Выходные данные |
|
1
|
4 100 200 1 1 4 2 3 3 2 4 0
|
210
|