A - Progressive Taxation Simulation Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233

問題文

高橋君は、ある国の税金計算システムを開発しています。

この国では、所得に対して以下のルールで税額が計算されます:

  • 所得の最初の L 円までの部分には税率 P % が適用される
  • 所得の L 円を超える部分には税率 Q % が適用される

ただし、P \leq Q とは限りません。

具体的には、所得が S 円の人の税額 T は次のように計算されます:

  • S \leq L のとき:T = \left\lfloor \dfrac{S \times P}{100} \right\rfloor
  • S > L のとき:T = \left\lfloor \dfrac{L \times P + (S - L) \times Q}{100} \right\rfloor

ここで \lfloor x \rfloorx を超えない最大の整数(床関数)を表します。

S > L のとき、切り捨ては L \times P の部分と (S-L) \times Q の部分それぞれに対して個別に行うのではなく、それらの合計 L \times P + (S - L) \times Q100 で割った結果に対して一度だけ行うことに注意してください。

例えば、L = 100P = 10Q = 23 のとき、所得が 150 円の人の税額は以下のように計算されます:

T = \left\lfloor \frac{100 \times 10 + (150 - 100) \times 23}{100} \right\rfloor = \left\lfloor \frac{1000 + 1150}{100} \right\rfloor = \left\lfloor \frac{2150}{100} \right\rfloor = \lfloor 21.5 \rfloor = 21 \text{ 円}

この例では、各項を個別に切り捨てた場合(\lfloor 10 \rfloor + \lfloor 11.5 \rfloor = 10 + 11 = 21 円)とたまたま同じ結果になりますが、一般には異なる場合があります。

N 人の納税者それぞれの所得額 S_i が与えられるので、各人の税額 T_i を求めてください。

制約

  • 1 \leq N \leq 10^5
  • 1 \leq L \leq 10^9
  • 0 \leq P \leq 100
  • 0 \leq Q \leq 100
  • 0 \leq S_i \leq 10^9 (1 \leq i \leq N)
  • 入力はすべて整数

入力

N L P Q
S_1
S_2
\vdots
S_N
  • 1 行目には、納税者の人数を表す整数 N、税率が切り替わる境界の所得額(円)を表す整数 L、所得の最初の L 円までの部分に適用される税率(%)を表す整数 P、所得の L 円を超える部分に適用される税率(%)を表す整数 Q が、スペース区切りで与えられる。
  • 2 行目から N + 1 行目には、各納税者の所得額が 1 行に 1 つずつ与えられる。
  • 1 + i 行目には、i 番目の納税者の所得額(円)を表す整数 S_i が与えられる。

出力

T_1
T_2
\vdots
T_N
  • N 行で出力する。
  • i 行目には、i 番目の納税者の税額 T_i を整数で出力する。

入力例 1

3 100 10 23
50
100
150

出力例 1

5
10
21

入力例 2

4 200 30 10
100
200
300
1

出力例 2

30
60
70
0

入力例 3

5 5000 15 40
0
3000
5000
8000
12345

出力例 3

0
450
750
1950
3688

入力例 4

8 1000000000 5 99
0
1
999999999
1000000000
1000000000
999999997
500000000
123456789

出力例 4

0
0
49999999
50000000
50000000
49999999
25000000
6172839

入力例 5

6 1 0 0
0
1
1000000000
0
0
1

出力例 5

0
0
0
0
0
0

Score : 233 pts

Problem Statement

Takahashi is developing a tax calculation system for a certain country.

In this country, the tax amount on income is calculated according to the following rules:

  • A tax rate of P % is applied to the first L yen of income
  • A tax rate of Q % is applied to the portion of income exceeding L yen

Note that P \leq Q does not necessarily hold.

Specifically, the tax amount T for a person with income S yen is calculated as follows:

  • When S \leq L: T = \left\lfloor \dfrac{S \times P}{100} \right\rfloor
  • When S > L: T = \left\lfloor \dfrac{L \times P + (S - L) \times Q}{100} \right\rfloor

Here, \lfloor x \rfloor denotes the largest integer not exceeding x (the floor function).

When S > L, note that the floor operation is applied only once to the result of dividing the sum L \times P + (S - L) \times Q by 100, rather than applying it individually to the L \times P part and the (S-L) \times Q part separately.

For example, when L = 100, P = 10, Q = 23, the tax amount for a person with income 150 yen is calculated as follows:

T = \left\lfloor \frac{100 \times 10 + (150 - 100) \times 23}{100} \right\rfloor = \left\lfloor \frac{1000 + 1150}{100} \right\rfloor = \left\lfloor \frac{2150}{100} \right\rfloor = \lfloor 21.5 \rfloor = 21 \text{ yen}

In this example, the result happens to be the same as when flooring each term individually (\lfloor 10 \rfloor + \lfloor 11.5 \rfloor = 10 + 11 = 21 yen), but in general they may differ.

Given the income S_i of each of N taxpayers, find each person's tax amount T_i.

Constraints

  • 1 \leq N \leq 10^5
  • 1 \leq L \leq 10^9
  • 0 \leq P \leq 100
  • 0 \leq Q \leq 100
  • 0 \leq S_i \leq 10^9 (1 \leq i \leq N)
  • All inputs are integers

Input

N L P Q
S_1
S_2
\vdots
S_N
  • The first line contains four space-separated integers: N representing the number of taxpayers, L representing the income threshold (in yen) at which the tax rate changes, P representing the tax rate (%) applied to the first L yen of income, and Q representing the tax rate (%) applied to the portion of income exceeding L yen.
  • From the 2nd line to the (N + 1)-th line, each taxpayer's income is given, one per line.
  • The (1 + i)-th line contains an integer S_i representing the income (in yen) of the i-th taxpayer.

Output

T_1
T_2
\vdots
T_N
  • Output N lines.
  • The i-th line should contain the tax amount T_i of the i-th taxpayer as an integer.

Sample Input 1

3 100 10 23
50
100
150

Sample Output 1

5
10
21

Sample Input 2

4 200 30 10
100
200
300
1

Sample Output 2

30
60
70
0

Sample Input 3

5 5000 15 40
0
3000
5000
8000
12345

Sample Output 3

0
450
750
1950
3688

Sample Input 4

8 1000000000 5 99
0
1
999999999
1000000000
1000000000
999999997
500000000
123456789

Sample Output 4

0
0
49999999
50000000
50000000
49999999
25000000
6172839

Sample Input 5

6 1 0 0
0
1
1000000000
0
0
1

Sample Output 5

0
0
0
0
0
0