|
5 | 5 | importjava.util.Map; |
6 | 6 | importjava.util.Set; |
7 | 7 |
|
8 | | -/** |
9 | | - * 1386. Cinema Seat Allocation |
10 | | - * |
11 | | - * A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above. |
12 | | - * Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i]=[3,8] means the seat located in row 3 and labelled with 8 is already reserved. |
13 | | - * Return the maximum number of four-person families you can allocate on the cinema seats. A four-person family occupies fours seats in one row, that are next to each other. |
14 | | - * Seats across an aisle (such as [3,3] and [3,4]) are not considered to be next to each other, however, It is permissible for the four-person family to be separated by an aisle, but in that case, exactly two people have to sit on each side of the aisle. |
15 | | - * |
16 | | - * Example 1: |
17 | | - * Input: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]] |
18 | | - * Output: 4 |
19 | | - * Explanation: The figure above shows the optimal allocation for four families, where seats mark with blue are already reserved and contiguous seats mark with orange are for one family. |
20 | | - * |
21 | | - * Example 2: |
22 | | - * Input: n = 2, reservedSeats = [[2,1],[1,8],[2,6]] |
23 | | - * Output: 2 |
24 | | - * |
25 | | - * Example 3: |
26 | | - * Input: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]] |
27 | | - * Output: 4 |
28 | | - * |
29 | | - * Constraints: |
30 | | - * 1 <= n <= 10^9 |
31 | | - * 1 <= reservedSeats.length <= min(10*n, 10^4) |
32 | | - * reservedSeats[i].length == 2 |
33 | | - * 1 <= reservedSeats[i][0] <= n |
34 | | - * 1 <= reservedSeats[i][1] <= 10 |
35 | | - * All reservedSeats[i] are distinct. |
36 | | - * */ |
37 | 8 | publicclass_1386 { |
38 | 9 | publicstaticclassSolution1 { |
39 | 10 | publicintmaxNumberOfFamilies(intn,int[][]reservedSeats) { |
|