Introduction
You are a supervisor of a parking lot and your manager is preparing for shrinking the size to the extreme.
It is a simplified and adapted version of a problem in last year's PAT top-level.
Challenge
You are asked to calculate how many cars are in the lot at the same time, at most.
Standard rules apply. And this is a code-golf so shortest code wins.
First line is the quantity of entries (no more than 100,000
, your input may not contain this line if you like, for it is only a makeshift to determine where input ends). The following text contains one entry per line. And each entry includes three numbers:
<Car plate number> <Time (seconds) since open> <0(In) | 1(Out)>
Modification 2: It is OK to use an array of triples as input.
Modification 3: You can change the order of numbers in one entry. And you can choose which to use. (see the Remarks section)
The input is guaranteed to be valid, assuming that:
Car plate number
is a integer in the range of10000
~99999
Time
is a integer in the range of0
~86400
And
- Entries are not necessarily chronologically ordered.
- There is no car before the first second.
- There is not necessarily no car after the last second.
- A car would not leave before it gets in.
Car plate number
is unique. (but a same car may visit for more than one time)- So it is impossible for a car to enter the lot when it is already in it.
- A same car wouldn't go in and out at the same
time
. - A car is considered to be in the lot at the time of in / out.
Example 1
Input
11
97845 36000 1
75487 16500 1
12345 16 0
75486 3300 0
12345 6500 1
97845 32800 0
12345 16400 0
97846 16501 1
97846 16500 0
75486 8800 1
75487 3300 0
Output
3
Explanation
At 16500
, car 12345
and 75487
were in the parking lot.
Example 2
I made this because I found many code failed on it.
Input (with first line left out)
12345 16400 0
12345 16500 1
75487 16500 0
75487 16600 1
Output
2
Explanation
At 16500
, car 12345
and 75487
were in the parking lot.
Remarks
Actually, not all three are required for the output. At least, you only need plate+time or in/out+time for the result. But the algorithm is slightly different under two circumstances, so the choice of being shorter stays unknown in a certain language. And of course you can use all of three numbers. So I leave them in the challenge.