#C1933. Warehouse Missed Pickups
Warehouse Missed Pickups
Warehouse Missed Pickups
You are managing a taco warehouse with limited storage. The warehouse can store a maximum of 10 unique taco types at any given time. Events occur in sequence, where a positive integer represents the delivery of a taco type (with that unique ID) and a negative integer represents a pickup request for a taco type. When a delivery arrives, if the warehouse has fewer than 10 taco types, the taco is added to storage. When a pickup request arrives, if the requested taco type is in the warehouse, it is removed; otherwise, the pickup is considered missed. Your task is to count the total number of missed pickups.
Note: Each taco delivery is unique. The events are processed in the given order.
The relationship can be summarized by the following process:
[
\text{if } event > 0:
\quad \text{if } |warehouse| < 10, ; add ; event ; to ; warehouse\
\text{if } event < 0:
\quad \text{if } |event| ; \in ; warehouse, ; remove it; ; otherwise, count as missed pickup
]
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains a single integer n, the number of events.
- The second line contains n space-separated integers representing the events.
Positive numbers represent deliveries, and negative numbers represent pickup requests.
outputFormat
Output a single integer to standard output (stdout) representing the total number of missed pickups.
## sample6
1 2 3 -1 -2 -4
1