#B4467. 分摊水费 / bill
分摊水费 / bill
Problem Description
Xiaoshan and Xiaoxi share an apartment and need to split the monthly water bill together. The water bill uses a tiered pricing system with the following rules:
- For the portion of total monthly water usage not exceeding cubic meters (including cubic meters), the rate is yuan per cubic meter.
- For the portion of total monthly water usage exceeding cubic meters, the rate is yuan per cubic meter.
Xiaoshan uses cubic meters of water per month, and Xiaoxi uses cubic meters of water per month.
They have agreed on a set of rules for splitting the total cost:
- If the total water usage does not exceed cubic meters, they split the cost equally.
- If the total water usage exceeds cubic meters, the cost for the first cubic meters is split equally, and the cost for the portion exceeding cubic meters is paid entirely by the person who uses more water (either or ).
Input Format
A single line containing two integers and , representing the water usage contributed by Xiaoshan and Xiaoxi respectively (in cubic meters). It is guaranteed that is not equal to .
Output Format
A single line containing two integers separated by a space, representing the final water bill amounts that Xiaoshan and Xiaoxi should pay respectively (in CNY).
5 4
18 18
5 6
20 25
Hint
[Sample Explanation]
, therefore they split the bill equally.
Total bill: , Split equally, so each person pays yuan.
[Sample Explanation]
, therefore they do not split the bill equally.
For the first cubic meters: ;
For the portion exceeding cubic meters: ;
They split the equally, and the remaining portion is paid by Xiaoxi. Therefore, Xiaoshan pays yuan, and Xiaoxi pays yuan.
[Constraints]
For of the test cases, .
For another of the test cases, .
For of the test cases, , and .
Translated by DeepSeek-V3