Parking lot supervisor 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:
&lt;Car plate number&gt; &lt;Time (seconds) since open&gt; &lt;0(In) | 1(Out)&gt;

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 of 10000 ~ 99999
Time is a integer in the range of 0 ~ 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.
Mathematica, 33 bytes

-Min@Accumulate[2#2-1&amp;@@@Sort@#]&amp;


I had to read the problem statement better to realize that there's a much simpler algorithm that doesn't require the license plate information.

Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}. We start by Sorting, which makes the list chronological and also breaks time-ties by sorting 0s before 1s; then 2#2-1&amp;@@@ keeps the arrival/departure information and forgets the rest, and also converts 0s to -1s.

Accumulate calculates the running totals of that list; the result is a list of the negatives of the numbers of cars in the parking lot after every arrival/departure. Then Min picks the smallest (most negative) of these and the negative sign is stripped.

Mathematica, 56 bytes

Max[&lt;|#|&gt;~Count~0&amp;/@FoldList[List,{},#3-&gt;#2&amp;@@@Sort@#]]&amp;


The original submission (the first several comments refer to this submission). Unnamed function returning an integer; the input format is a list of ordered triples in the form {time, 0|1, license plate}.

The reason we choose to put the time entry first and the in/out entry second is so that Sort@# sorts the list chronologically, and records arrivals before departures if they're simultaneous. After that, #3-&gt;#2&amp;@@@ returns a list of "rules" of the form license plate -&gt; 0|1, still sorted chronologically.

Then, FoldList[List,{},...] creates a list of all the initial segments of that list of rules. Actually, it really messes up those initial segments; the kth initial segment ends up being a list with one rule at depth 2, one rule at depth 3, ..., and one rule at depth k+1. (FoldList[Append,{},...] would yield the more natural result.) However, &lt;|#|&gt; turns each of these initial segments into an "association", which has two desirable effects: first, it completely flattens the nested-list structure we just created; and second, it forces later rules to override earlier rules, which is exactly what we need here—for any car that has left the parking lot, the record of its initial entry is now completely gone (and similarly for cars that re-enter).

So all that's left to do is to Count how many 0s there are in each of these associations, and take the Max.