/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
駐車場があります。この駐車場に駐車するときの料金は以下の通りです。
- L 時ちょうどから R 時ちょうどまでのあいだは、1 時間停めるごとに X の料金がかかる
- 上に該当しない時間のあいだは、1 時間停めるごとに Y の料金がかかる
この駐車場に、日をまたぐことなく車を A 時ちょうどから B 時ちょうどまで停めたとき、料金はいくらになりますか?
制約
- 1 \leq X, Y \leq 1000
- 1 \leq L < R \leq 23
- 1 \leq A < B \leq 23
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
X Y L R A B
出力
答えを出力せよ。
入力例 1
700 300 9 17 7 21
出力例 1
7400
車を 7 時から 21 時のあいだ停めたとき、かかる料金は以下のようになります。
- 7 時から 9 時までの 2 時間は 300 \times 2 = 600 の料金がかかる
- 9 時から 17 時までの 8 時間は 700 \times 8 = 5600 の料金がかかる
- 17 時から 21 時までの 4 時間は 300 \times 4 = 1200 の料金がかかる
600 + 5600 + 1200 = 7400 が求める答えです。
入力例 2
600 500 9 17 17 20
出力例 2
1500
車を 17 時から 20 時のあいだ停めたとき、かかる料金は以下のようになります。
- 17 時から 20 時までの 3 時間は 500 \times 3 = 1500 の料金がかかる
1500 が求める答えです。
入力例 3
900 200 12 14 11 13
出力例 3
1100
Score : 200 points
Problem Statement
There is a parking lot. The fee for parking in this lot is as follows:
- During the period from exactly L o'clock to exactly R o'clock, a fee of X is charged for each hour parked.
- During the period not covered above, a fee of Y is charged for each hour parked.
If a car is parked in this lot from exactly A o'clock to exactly B o'clock without crossing midnight, how much is the fee?
Constraints
- 1 \leq X, Y \leq 1000
- 1 \leq L < R \leq 23
- 1 \leq A < B \leq 23
- All input values are integers.
Input
The input is given from Standard Input in the following format:
X Y L R A B
Output
Output the answer.
Sample Input 1
700 300 9 17 7 21
Sample Output 1
7400
If a car is parked from 7 o'clock to 21 o'clock, the fee is as follows.
- For the 2 hours from 7 o'clock to 9 o'clock, a fee of 300 \times 2 = 600 is charged.
- For the 8 hours from 9 o'clock to 17 o'clock, a fee of 700 \times 8 = 5600 is charged.
- For the 4 hours from 17 o'clock to 21 o'clock, a fee of 300 \times 4 = 1200 is charged.
The answer is 600 + 5600 + 1200 = 7400.
Sample Input 2
600 500 9 17 17 20
Sample Output 2
1500
If a car is parked from 17 o'clock to 20 o'clock, the fee is as follows.
- For the 3 hours from 17 o'clock to 20 o'clock, a fee of 500 \times 3 = 1500 is charged.
The answer is 1500.
Sample Input 3
900 200 12 14 11 13
Sample Output 3
1100