#P1077. [NOIP 2012 普及组] 摆花

    ID: 1905 远端评测题 1000ms 125MiB 尝试: 75 已通过: 30 显示难度普及− 上传者: 标签>模拟动态规划 DP2012NOIP 普及组

[NOIP 2012 普及组] 摆花

Problem Description

Xiaoming’s flower shop has just opened. To attract customers, he wants to place a row of mm pots of flowers at the entrance. Based on a survey, he listed the nn most popular types of flowers, numbered from 11 to nn. To showcase more types, it is required that for each type ii, no more than aia_i pots are used. When arranging, flowers of the same type must be placed together, and different types must be placed in increasing order of their labels.

Write a program to compute how many different arrangements there are.

Input Format

The first line contains two positive integers nn and mm, separated by a single space.

The second line contains nn integers, separated by single spaces, representing a1,a2,⋯ ,ana_1, a_2, \cdots, a_n.

Output Format

Output a single integer, the number of arrangements. Note: since the number may be large, output the answer modulo 106+710^6 + 7.

2 4
3 2

2

Hint

Constraints

  • For 20%20\% of the testdata: 0<n≤80 < n \le 8, 0<m≤80 < m \le 8, 0≤ai≤80 \le a_i \le 8.
  • For 50%50\% of the testdata: 0<n≤200 < n \le 20, 0<m≤200 < m \le 20, 0≤ai≤200 \le a_i \le 20.
  • For 100%100\% of the testdata: 0<n≤1000 < n \le 100, 0<m≤1000 < m \le 100, 0≤ai≤1000 \le a_i \le 100.

NOIP 2012 Junior Problem 3.

Translated by ChatGPT 5