No.1517 Party Location
タグ : / 解いたユーザー数 280
作問者 :
aspi
/ テスター :
Nachia
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
There are two towns, Town A and Town B, on a number line. Town A is located at the origin, that is, at coordinate $0$, and Town B is located at coordinate $d$.
One day, it was decided that the residents of both towns would hold a party.
$a$ people from Town A and $b$ people from Town B will attend the party.
You, the organizer, choose a real number $x$ satisfying $0 \leq x \leq d$ and set the coordinate $x$ as the party venue.
However, since traveling incurs a cost, you want to minimize the value of the hosting cost $:=x \times a + (d - x) \times b$.
What is this minimum value? It can be shown that this value is always an integer under the constraints.
Input
$d$ $a\ b$
- All inputs are integers.
- $0 \leq d \leq 10000$
- $0 \leq a, b \leq 1000$
Output
Output the minimum hosting cost as an integer.
Print a newline at the end.
Sample
Sample 1
Input
10 20 20
Output
200
For example, by setting $x=5$, that is, by choosing the point at distance $5$ from Town A as the party venue, the hosting cost can be made $5 \times 20 + 5 \times 20 = 200$.
Sample 2
Input
5 0 100
Output
0
Since nobody comes to the party from Town A, it is best to hold the party in Town B, and the hosting cost is $5 \times 0 + 0 \times 100=0$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。