Public Judge

pjudge

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#21863. 【NOIP Round #8】降雨

الإحصائيات

题目描述

有 $n$ 个宽度为 $1$ 的柱子从左到右排列,它们两侧相连。从左向右数第 $i$ 个柱子的高度为 $h_i$。

当下雨时,水可能会积聚在某些地方,比如两个高柱子之间有短柱子的情况下。

形式化的说,如果某个点不在柱子内部,点左侧和右侧均有格子高度不低于它,那么这个点就会积水。

例如下图展示了一个 $n = 10$,柱子高度分别为 $4, 2, 1, 8, 6, 2, 7, 1, 2, 3$ 的例子,积水的体积为 $2+3+1+5+2+1=14$。

有一天天降大雨,在雨后,坑洼的部分会产生积水。

你决定平整某些柱子,即,选出一些柱子使其高度变为 $0$,但是你只能平整恰好 $k$ 个柱子。

现在你想知道,在所有的 $\binom nk$ 种施工方案中,有多少种方案会使得最终的积水体积是偶数?答案对 $10^9+7$ 取模输出。

输入格式

第一行两个整数 $n,k$。

第二行 $n$ 个整数,表示 $h_i$。

输出格式

一个整数,表示答案对 $10^9+7$ 取模后的值。

样例输入 1

7 1
2 5 2 4 1 6 2

样例输出 1

4

样例输入/输出 2~9

见下发文件。

数据范围

对于所有数据,有:$1\le n\le 25000,1\le h_i\le 10^9,0\le k\le \min\{25,n-1\}$。

子任务编号 特殊性质 分值
$1$ $n \le 15,h_i \le 10$ $10$
$2$ $n \le 40$ $12$
$3$ $n \le 400, k\le 8$ $8$
$4$ $n \le 400$ $6$
$5$ $n \le 3000,k \le 8$ $8$
$6$ $k \le 8$ $10$
$7$ $n \le 3000$ $12$
$8$ $h_i \le h_{i+1}$ $10$
$9$ $24$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.