report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Soil - MarisaOJ: Marisa Online Judge

Soil

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has a garden with $n$ plots, and each plot $i$ initially contains $A_i$ units of soil. Marisa wants to modify the amount of soil in each plot so that they contain $B_i$ units of soil. Marisa can perform the following actions, each with its associated cost: - Buy an additional unit of soil at a cost of $x$. - Dump a unit of soil from a plot at a cost of $y$. - Move an unit of soil from plot $i$ to plot $j$ at a cost of $|i-j| \times z$. Your task is to determine the minimum cost for Marisa to renovate her garden by adjusting the soil in each plot. ### Input - The first line contains four integers $n,x,y,z$. - The next $n$ lines, each line contains two integers $A_i,B_i$. ### Output - Print an integer, the minimum cost. ### Constraints - $1 \le n \le 500$. - $1 \le x, y, z \le 1000$. - $0 \le A_i, B_i \le 10$. ### Example Input: ``` 4 100 200 1 1 4 2 3 3 2 4 0 ``` Output: ``` 210 ```
Introduction to Dynamic Programming (Part two)
Sake game
Coins
Coins 2
Game on array
Longest increasing subsequence 2
Convolution
Regular bracket sequence
Faulty addition
Weird bank
Delete operation
Palindromize
Color ribbon
Unique subsequences
Unique subsequences 2
Cow exhibition
Knapsack 3
Compressing array
Regular bracket sequence 2
Maximum path 3
Concating substring
Soil
Stacking boxes
String transformation
Palindromic quadruple
Finding teammates
Topic
Dynamic Programming
Rating 1700
Solution (0) Solution