#C1647. Total Units Sold Calculation

    ID: 44875 Type: Default 1000ms 256MiB

Total Units Sold Calculation

Total Units Sold Calculation

Given multiple sales records, each of which contains a product ID, a timestamp, and the number of units sold, your task is to calculate the total units sold for each product within a specified time interval.

For each record with timestamp \(t\), count it in the total if \(start\_time \leq t \leq end\_time\). The final result should be a list of pairs \((product\_id, total\_units\_sold)\) sorted by the product ID in ascending order.

inputFormat

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

  • The first line contains an integer \(n\) representing the number of sales records.
  • Each of the next \(n\) lines contains three space-separated integers: product_id, timestamp, and units_sold.
  • The last line contains two space-separated integers: start_time and end_time, representing the inclusive time interval.

outputFormat

The output is printed to stdout. For each product that has sales in the given time interval, print a line with the product ID and the total units sold separated by a space. The output should be sorted by product ID in ascending order. If no records match the interval, output nothing.

## sample
5
1 1618310400 5
2 1618310500 3
1 1618310600 2
3 1618310700 8
2 1618310800 4
1618310400 1618310800
1 7

2 7 3 8

</p>