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

Brewing potion 8

Time limit: 1000 ms
Memory limit: 256 MB
Marisa has $n$ colorful potion bottles arranged in a row. Each bottle, labeled $i$, has a color $A_i$ ranging from $0$ to $99$. Marisa aims to combine all the bottles into a single bottle. She can select two adjacent bottles with colors $a$ and $b$, and mix them to create a new bottle with a color of $(a+b) \mod 100$. The amount of fumes released during this mixing process is given by $a \times b$. To minimize the amount of fumes released, Marisa needs to determine the minimum amount of fumes when she mixes all $n$ bottles together. ### Input - A single line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the minimum amount of fumes. ### Constraints - $1 \le n \le 500$. ### Example Input: ``` 3 40 60 20 ``` Output: ``` 2400 ```
Introduction to dynamic programming
Hakurei Shrine
Buying tickets
Reading 2
Longest increasing subsequence
Jealousy
Maximum path 2
Fences painting
Hall
Knapsack 2
Longest common subsequence
Yet another build array problem
Rectangle cutting
Palindrome query
Marisa
Merging elements
Brewing potion 8
Topic
Dynamic Programming
Rating 1200
Solution (0) Solution