← 返回 stripe 的题目列表Calculate Service Fees
类型:online_judge
Problem: Calculate Service Fees
Implement a simple payment service fee calculator. You are given a list of payment transactions. Each transaction contains a transaction ID, a payment method, and an amount in cents. Calculate the service fee for each transaction and the total fee across all transactions.
Fee Rules
All monetary values are integer cents. Whenever a percentage-based fee produces a fractional cent, round it up to the next cent.
| payment_method | Fee Rule | |---|---| | card | 2.9% of the amount, rounded up, plus a fixed 30 cents fee | | bank | 0.8% of the amount, rounded up, capped at 500 cents per transaction | | wallet | 1.5% of the amount, rounded up |
Input Format
The first line contains an integer n, the number of transactions.
Each of the next n lines contains:
transaction_id payment_method amount_cents
Where:
transaction_id is a string without spaces;
payment_method is one of card, bank, or wallet;
amount_cents is a positive integer.
Output Format
For each transaction, output one line in the original input order:
transaction_id fee_cents
Finally, output:
TOTAL total_fee_cents
Constraints
1 <= n <= 100000
1 <= amount_cents <= 10^12
Example
Input:
3
ch_1 card 10000
ch_2 bank 100000
ch_3 wallet 999
Output:
ch_1 320
ch_2 500
ch_3 15
TOTAL 835
Example
Input
3
ch_1 card 10000
ch_2 bank 100000
ch_3 wallet 999
Output
ch_1 320
ch_2 500
ch_3 15
TOTAL 835