Maximum Four-Person Families in a Cinema. The cinema has n rows and10 numbered seats per row. A four-person family may occupy exactly one of these blocks within a row: seats2..5,4..7,or6..9.
### Problem
The cinema has n rows and 10 numbered seats per row. A four-person family may occupy exactly one of these blocks within a row: seats 2..5,4..7,or 6..9. Reserved seats cannot be used, and families cannot share seats. Return the maximum number of families that can be seated.
```cpp
class Solution {
public:
int maxNumberOfFamilies(int n, vector<vector<int>>& reservedSeats);
};
```
### Examples
**Example 1:**
```text
Input: n = 2, reservedSeats = [[1,4],[2,7]]
Output: 2
Explanation: Use seats6..9 in row1 and seats2..5 in row2; neither row permits two families.
```
**Example 2:**
```text
Input: n = 3, reservedSeats = [[2,1],[2,10]]
Output: 6
Explanation: Seats1 and10 belong to none of the allowed blocks, so every row still fits two families.
```
### Constraints
- `1 <= n <= 1000000000`.
- There are 1 to min(10*n,10000) distinct reserved seat pairs.
- Each pair has row in `[1,n]` and seat in `[1,10]`.
### Contract considerations
The three stated blocks encode the aisle rule, including the permitted split across the aisle.
```hint Read the boundary condition
Check overlapping family placements and reservations at the outside seats. Count families across all rows, including rows without reservations.
```
### Boundary reminders
The three stated blocks encode the aisle rule, including the permitted split across the aisle.
Overview: Maximum Four-Person Families in a Cinema. The cinema has n rows and10 numbered seats per row. A four-person family may occupy exactly one of these blocks within a row: seats2..5,4..7,or6..9.
The cinema has n rows and 10 numbered seats per row. A four-person family may occupy exactly one of these blocks within a row: seats 2..5,4..7,or 6..9. Reserved seats cannot be used, and families cannot share seats. Return the maximum number of families that can be seated.
class Solution {
public:
int maxNumberOfFamilies(int n, vector<vector<int>>& reservedSeats);
};
Examples
Example 1:
Input: n = 2, reservedSeats = [[1,4],[2,7]]
Output: 2
Explanation: Use seats6..9 in row1 and seats2..5 in row2; neither row permits two families.
Example 2:
Input: n = 3, reservedSeats = [[2,1],[2,10]]
Output: 6
Explanation: Seats1 and10 belong to none of the allowed blocks, so every row still fits two families.
Constraints
1 <= n <= 1000000000
.
There are 1 to min(10*n,10000) distinct reserved seat pairs.
Each pair has row in
[1,n]
and seat in
[1,10]
.
Contract considerations
The three stated blocks encode the aisle rule, including the permitted split across the aisle.
Boundary reminders
The three stated blocks encode the aisle rule, including the permitted split across the aisle.