Social Distancing
InterviewTime limit1sMemory limit1024 MB
Given S circular seats with N occupied, find how many more people can sit so that no two seated people are adjacent.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
It is time for a social distancing party! A group of friends are sitting around a circular table. Some seats are filled and some are empty. To follow the distancing rules, no two people sit directly beside each other.
The friends want to expand the party and invite more people, but no one is willing to move from their current seat. Given the current seating, find the maximum number of additional people who can be seated so that every pair of seated people still has at least one empty seat between them.
Input
The first line contains two integers () and (). is the number of seats at the table, and is the number of people already seated.
The seats are numbered in a circle. For each , seats and are directly beside each other. Seats and are also directly beside each other.
The second line contains integers (), meaning seat is already occupied. No two occupied seats are directly beside each other.
Output
Print the maximum number of additional people who can be seated at the table so that there is still at least one empty seat between every pair of seated people.