CF1845E.Boxes and Balls

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn boxes placed in a line. The boxes are numbered from 11 to nn . Some boxes contain one ball inside of them, the rest are empty. At least one box contains a ball and at least one box is empty.

In one move, you have to choose a box with a ball inside and an adjacent empty box and move the ball from one box into another. Boxes ii and i+1i+1 for all ii from 11 to n1n-1 are considered adjacent to each other. Boxes 11 and nn are not adjacent.

How many different arrangements of balls exist after exactly kk moves are performed? Two arrangements are considered different if there is at least one such box that it contains a ball in one of them and doesn't contain a ball in the other one.

Since the answer might be pretty large, print its remainder modulo 109+710^9+7 .

输入格式

The first line contains two integers nn and kk ( 2n15002 \le n \le 1500 ; 1k15001 \le k \le 1500 ) — the number of boxes and the number of moves.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( ai{0,1}a_i \in \{0, 1\} ) — 00 denotes an empty box and 11 denotes a box with a ball inside. There is at least one 00 and at least one 11 .

输出格式

Print a single integer — the number of different arrangements of balls that can exist after exactly kk moves are performed, modulo 109+710^9+7 .

输入输出样例

  • 输入#1

    4 1
    1 0 1 0

    输出#1

    3
  • 输入#2

    4 2
    1 0 1 0

    输出#2

    2
  • 输入#3

    10 6
    1 0 0 1 0 0 0 1 1 1

    输出#3

    69

说明/提示

In the first example, there are the following possible arrangements:

  • 0 1 1 0 — obtained after moving the ball from box 11 to box 22 ;
  • 1 0 0 1 — obtained after moving the ball from box 33 to box 44 ;
  • 1 1 0 0 — obtained after moving the ball from box 33 to box 22 .

In the second example, there are the following possible arrangements:

  • 1 0 1 0 — three ways to obtain that: just reverse the operation performed during the first move;
  • 0 1 0 1 — obtained from either of the first two arrangements after the first move.
首页