#K38287. Taco Sales Summary

    ID: 26165 Type: Default 1000ms 256MiB

Taco Sales Summary

Taco Sales Summary

You are given a sequence of sales transactions. Each transaction consists of four values:

  • Transaction ID (an integer),
  • Customer ID (an integer),
  • Product ID (an integer),
  • Amount Spent (a floating-point number).

Your task is to compute, for each customer, the total amount spent across all transactions. In mathematical terms, for each customer \( c \), compute:

[ S_c = \sum_{i \in T(c)} a_i ]

where \( T(c) \) is the set of transactions corresponding to customer \( c \) and \( a_i \) is the amount spent in transaction \( i \).

The results should be output in the ascending order of Customer IDs.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains a single integer \( N \) representing the number of transactions.
  2. The next \( N \) lines each contain four space‐separated values: transaction_id customer_id product_id amount_spent.

For example:

5
1 101 2001 150.0
2 102 2002 200.0
3 101 2003 50.0
4 103 2004 300.0
5 102 2001 70.0

outputFormat

The output should be written to standard output (stdout) and consists of several lines. Each line contains a customer ID and the corresponding total amount spent by that customer, separated by a space.

The customer IDs should be output in ascending order. For example:

101 200.0
102 270.0
103 300.0
## sample
5
1 101 2001 150.0
2 102 2002 200.0
3 101 2003 50.0
4 103 2004 300.0
5 102 2001 70.0
101 200.0

102 270.0 103 300.0

</p>