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

32796번 - Rainbow Bowl Ranges 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB90231928.788%

문제

You have a set of $n$ bowls, arranged in a circle.

You have many balls of various colors. There are $m$ different colors, and you have $c_i$ balls of the $i^th$ color.

You want to distribute all the balls into the bowls. To do this, for each color, you choose a contiguous range of bowls of size $c_i$ and place one ball of that color in each bowl in the range. A contiguous range of bowls is a set of consecutive bowls around the circle. Ranges from different colors are allowed to overlap.

A bowl is rainbow if it contains one ball of each color. A rainbow bowl range is a contiguous range of rainbow bowls that cannot be extended by including another rainbow bowl.

You want to arrange balls in bowls to maximize the number of rainbow ranges.

Given the number of bowls and the number of balls of each color, what is the maximum number of rainbow bowl ranges that can be formed?

입력

The first line contains two integers, $n$ $(2 \le n \le 10^9),ドル $m$ $(1 \le m \le 10^5)$.

The next $m$ lines each contain a single integer, $c_i$ $(1 \le c_i \le n)$.

출력

Print a single integer, the maximum number of rainbow bowl ranges that can be formed.

제한

예제 입력 1

4 2
3
3

예제 출력 1

2

예제 입력 2

10 11
3
1
4
1
5
9
2
6
5
3
5

예제 출력 2

1

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 1 J번

ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 2 K번

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

출처

대학교 대회

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

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