Warehouse management

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Ha Minh Ngoc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

ABC Company needs to upgrade its current warehouse management software. The new software needs to be able to manage import/export transactions with a rule that first-in, first-out products are given priority. Given a list of transactions to be processed in order (output transactions larger than the inventory count will not be processed), output the products in stock after executing the transactions knowing that Initially there are no products in warehouse.

Input

  • The first line is the number of transactions (~N~ ≤ ~10^{6}~).

  • The ~ith~ line in the next ~N~ lines begins with a ~+/-~ sign corresponding to an import/export transaction, followed by 4 integers ~Ci~, ~Qi~, ~Pi~ and ~Ti~, respectively, the item code, quantity, and unit price of the product. per product, time of transaction (~Qi~, ~Pi~, ~Ti~ ≤ ~10^{9}~, ~Ci~ with no more than 9 digits). The time of the following transaction is always greater than or equal to the previous transaction.

Output

  • For each product in stock, output the product code, quantity, average value of each product based on the input price, and the time of oldest item separated by a space.

  • Products are printed in ascending order of product code, the average value rounded down to the unit

Sample Input:

6
+ 1 25 20000 1
- 1 20 30000 2
+ 2 15 30000 2
- 2 25 25000 4
- 2 5 20000 5
+ 2 15 20000 5

Sample Output:

1 5 20000 1
2 25 24000 2

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.