Submit | All submissions | Best solutions | Back to list |
EIUMCM - MEMBER CARD MANAGEMENT |
Store chain X implements a membership program with discount policies based on each customer's total previous spending within 1 year (365 days counting backward from the current transaction date).
Discount rates:
- Total spending from 5 million VND and above: 5% discount
- Total spending from 10 million VND and above: 10% discount
- Total spending from 20 million VND and above: 12% discount
- Total spending from 50 million VND and above: 15% discount
- Total spending from 100 million VND and above: 17% discount
- Total spending from 200 million VND and above: 20% discount
- Total spending from 300 million VND and above: 22% discount
- Total spending from 500 million VND and above: 25% discount
Given a list of N transactions, each represented by a triplet (IDi, Ti, Ci) where:
- IDi is the customer ID for the transaction
- Ti is the day the purchase was made
- Ci is the actual cost paid for that purchase
Knowing that a year has 365 days. Transactions for each customer will be in increasing order of time.
Calculate the total amount of money all customers saved by participating in this membership program compared to not participating.
Input
- The first line contains a single integer N (1 ≤ N ≤ 105), the total number of transactions.
- The next N lines each contain three values: IDi, Ti, and Ci (1 ≤ IDi ≤ 104, 1 ≤ Ti ≤ 105, 1 ≤ Ci ≤ 109) representing the customer ID, purchase day, and actual cost paid, respectively.
Output
A single number representing the total amount of money saved by all customers (round to nearest integer).
Example
Input |
Output |
2 101 1 6000000 101 10 7000000 |
368421 |
5 101 1 6000000 101 10 7000000 101 20 8000000 102 5 4000000 102 15 9000000 |
1257310
|
7 201 1 3000000 201 100 4000000 201 200 5000000 201 400 8000000 202 10 2000000 202 50 6000000 202 300 12000000 |
1315789 |
Added by: | Ha Minh Ngoc |
Date: | 2025-07-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |