#C1319. Maximum Consecutive Non-Overlapping Events
Maximum Consecutive Non-Overlapping Events
Maximum Consecutive Non-Overlapping Events
In a given theater, there are ( n ) rows and ( m ) seats per row. Some rows are already occupied by events. Each event occupies an entire row. Your task is to determine the maximum number of consecutive events that can be scheduled in the unoccupied rows. The answer is computed by subtracting the number of unique occupied rows from ( n ). For example, if there are 5 rows and 4 rows are occupied, you can schedule ( 5 - 4 = 1 ) consecutive event.
inputFormat
The input consists of one or two lines. The first line contains three integers ( n ), ( m ), and ( e ) separated by spaces, where ( n ) is the total number of rows, ( m ) is the number of seats per row (which is not used in computation), and ( e ) is the number of events already scheduled (i.e. the number of occupied rows). If ( e > 0 ), the second line contains ( e ) distinct integers representing the occupied row numbers.
outputFormat
Output a single integer, which is the maximum number of consecutive events that can be held without overlaps, calculated as ( n - \text{number of occupied rows} ).## sample
5 10 4
1 2 3 4
1