H. Annuity Payment Scheme

Codeforces
IDCF10125H
Time1000ms
Memory64MB
Difficulty
English · Original
Formal · Original
At the peak of the Global Economic Crisis BerBank offered an unprecedented credit program. The offering was so attractive that Vitaly decided to try it. He took a loan of s burles for m months with the interest rate of p percent. Vitaly has to follow the scheme of annuity payments, meaning that he should make fixed monthly payments — x burles per month. Obviously, at the end of the period he will pay m·x burles to the bank in total. Each of the monthly payments is divided by BerBank into two parts as follows: For example, if s = 100, m = 2, p = 50 then x = 90. For the first month a1 = s'·p / 100 = s·p / 100 = 50 and b1 = 90 - 50 = 40. For the second month a2 = (100 - 40)·50 / 100 = 30, so b2 = 90 - 30 = 60 and the debt is paid off completely. Your task is to help Vitaly and write a program that computes x given the values of s, m and p. The single line of the input contains three integers s, m and p (1 ≤ s ≤ 106, 1 ≤ m ≤ 120, 0 ≤ p ≤ 100). Output the single value of monthly payment x in burles. An absolute error of up to 10 - 5 is allowed. ## Input The single line of the input contains three integers s, m and p (1 ≤ s ≤ 106, 1 ≤ m ≤ 120, 0 ≤ p ≤ 100). ## Output Output the single value of monthly payment x in burles. An absolute error of up to 10 - 5 is allowed. [samples]
**Definitions** Let $ n \in \mathbb{Z} $ be the number of cards, with $ 2 \leq n \leq 10^5 $. Let $ V = (v_1, v_2, \dots, v_n) $ be a sequence of integers, where $ 1 \leq v_i \leq 5000 $ for all $ i \in \{1, \dots, n\} $. **Constraints** - Initially, each card is a singleton set: $ \{v_1\}, \{v_2\}, \dots, \{v_n\} $. - In each move, two adjacent sets are merged into one. - The game ends when only one set remains. - After each merge, the score increases by the maximum value in each existing set. **Objective** Maximize the total score, defined as the sum of the maximum value over all current sets after each merge operation. **Key Insight** The total score equals the sum over all cards of $ v_i \cdot c_i $, where $ c_i $ is the number of times the value $ v_i $ is the maximum in a set during the merging process. To maximize the score, each $ v_i $ contributes as many times as the number of intervals (contiguous subarrays) in which it is the maximum. Thus, the maximum score is: $$ \sum_{i=1}^{n} v_i \cdot L_i \cdot R_i $$ where: - $ L_i $ is the number of consecutive elements to the left of $ v_i $ (including $ v_i $) that are $ \leq v_i $, - $ R_i $ is the number of consecutive elements to the right of $ v_i $ (including $ v_i $) that are $ \leq v_i $, and the product $ L_i \cdot R_i $ gives the number of contiguous subarrays where $ v_i $ is the maximum. **Note**: This is equivalent to the standard "sum of maximums of all subarrays" problem.
API Response (JSON)
{
  "problem": {
    "name": "H. Annuity Payment Scheme",
    "description": {
      "content": "At the peak of the Global Economic Crisis BerBank offered an unprecedented credit program. The offering was so attractive that Vitaly decided to try it. He took a loan of s burles for m months with th",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10125H"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "At the peak of the Global Economic Crisis BerBank offered an unprecedented credit program. The offering was so attractive that Vitaly decided to try it. He took a loan of s burles for m months with th...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of cards, with $ 2 \\leq n \\leq 10^5 $.  \nLet $ V = (v_1, v_2, \\dots, v_n) $ be a sequence of integers, where $ 1 \\leq v_i \\leq 5000 $ for all $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments