Sales Report
Time limit4sMemory limit128 MB
Given N sale records of item, salespoint, and quantity, print a table of totals with items as columns and salespoints as rows.
- Level
Medium4 of 10
- Topics
- Sorting, Hash map, Implementation, Matrix
- Solved
- No attempts yet
Problem
The Unknown Trading Company has installed a new inventory-tracking system that stores a complete database of goods and trading points worldwide. Each salespoint and each item is assigned a unique integer identifier (id). For every sale, the system logs the id of the item, the number of items sold, and the id of the salespoint.
Output a summary report that tabulates total sales by item and by salespoint. The report is a two-dimensional table that follows these rules:
- The first row lists the item ids in increasing order.
- The first column lists the salespoint ids in increasing order.
- Each inner cell holds the total quantity of the corresponding item sold from the corresponding salespoint.
- The value in the first column of the first row (the top-left corner) is .
- A cell with no corresponding sale holds .
Input
The first line contains the number of records . Each of the next lines contains three integers , where is the item id, is the salespoint id, and is the number of items sold.
Output
Print the table described above, one row per line, with the values in each row separated by single spaces.
Constraints
- The summary table has at most cells.
- The summary value in each cell does not exceed .