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

28201번 - 5 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 555 MB238545.455%

문제

You are given an array $a$ of length $n$ consisting of non-negative integers. Calculate the number of pairs $(k, T)$ such that there exists a subsequence of $a$ of length $k$ whose sum is equal to $T$.

Just kidding, this is too general. Suppose the sum of elements of $a$ is equal to $S,ドル then it is guaranteed that $a$ has at least $S/5$ elements equal to 1ドル$.

입력

The first line contains two positive integers $n$ and $S$ (1ドル \le n, S \le 2 \cdot 10^5$) --- the number of elements in $a$ and their sum.

The second line contains the array $a_1, a_2, \ldots, a_n$ (0ドル \le a_i \le S$). It is guaranteed that $\sum_{i=1}^{n} a_i = S$ and at least $S/5$ elements of $a$ are equal to 1ドル$.

출력

Print the number of pairs $(k, T)$ such that there exists a subsequence of $a$ of length $k$ whose sum is equal to $T$.

제한

예제 입력 1

7 9
0 0 0 1 1 2 5

예제 출력 1

42

예제 입력 2

10 33
9 9 8 1 1 1 1 1 1 1

예제 출력 2

48

예제 입력 3

10 14
2 4 4 1 0 1 0 1 0 1

예제 출력 3

81

예제 입력 4

10 14
3 5 3 0 1 0 1 0 1 0

예제 출력 4

87

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2023 > Day 6: Um_nik mod 998 244 353 Contest L번

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

출처

대학교 대회

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

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