#P11569. 「chaynOI R1 T2」画图软件

「chaynOI R1 T2」画图软件

Background

14:27 Added the sample explanation for T2.

Problem Description

You are given a sequence aa. You can perform at most kk "pen down" operations. Each time, choose a position p(1pn)p(1 \le p \le n) and set apap+1a_p \gets a_p + 1 (that is, add 11 to the pp-th term of aa). Find the number of possible final sequences such that aa becomes an arithmetic progression with a non-negative common difference.

Input Format

The first line contains two integers n,kn, k.

The second line contains nn integers, representing the sequence aa.

Output Format

Output one integer in one line, representing the answer.

5 6
1 2 3 4 5
2

Hint

Sample Explanation

There are (1,2,3,4,5)(1,2,3,4,5) and (2,3,4,5,6)(2,3,4,5,6), 22 possibilities in total.

Constraints

For 100%100\% of the testdata, 1n,ai1061 \le n, a_i \le 10^6, and k107k \le 10^7.

This problem uses bundled tests.

  • Subtask 1 (20 pts): n,k100n, k \le 100.
  • Subtask 2 (15 pts): n100n \le 100.
  • Subtask 3 (15 pts): k105k \le 10^5.
  • Subtask 4 (50 pts): No special constraints.

Translated by ChatGPT 5