Logo
(追記) (追記ここまで)

24753번 - Social Distancing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB107635858.586%

문제

It's time for a social distancing party! A group of friends are sitting around a circular table where some seats are filled and some seats are empty. In particular, to maintain social distancing protocols, no two people are sitting directly beside each other.

They want to expand the party and include more friends, but no one is willing to move out of their current seat. Given the current table seating, determine the maximum number of additional people that can be seated such that there is still at least one empty seat between all pairs of people seated.

입력

The first line of input contains two integers $S$ (3ドル \leq S \leq 1,000円$), which is the number of seats at the table, and $N$ (1ドル \leq N \leq S/2$), which is the number of people that are already seated at the table.

Note that the seats of the table are numbered 1,ドル 2, \ldots, S$ in a circular fashion: for each 1ドル \leq i < S,ドル seats numbered $i$ and $i+1$ are directly beside each other. Seats $S$ and 1ドル$ are also directly beside each other.

The second line contains $N$ integers $a_1, a_2, \ldots, a_N$ (1ドル \leq a_1 < a_2 < \cdots < a_N \leq S$), which indicates that seat number $a_{i}$ is currently occupied. No two occupied seats are directly beside each other.

출력

Display the maximum number of additional friends that can be seated at the table such that there is still at least one empty seat between all pairs of people seated.

제한

예제 입력 1

9 2
2 6

예제 출력 1

2

예제 입력 2

10 3
1 4 7

예제 출력 2

1

예제 입력 3

6 2
2 5

예제 출력 3

0

예제 입력 4

100 5
7 14 47 78 99

예제 출력 4

43

예제 입력 5

6 1
3

예제 출력 5

2

힌트

출처

ICPC > Regionals > North America > Rocky Mountain Regional > 2021 Rocky Mountain Regional Contest C번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /