QOJ.ac

QOJ

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

#22624. 滑雪缆车

Statistics

科罗拉多的 Farmer Ron 给奶牛建滑雪场,预算只够一条缆车。缆车采用单轨,由起点混凝土支撑经若干中间支撑连接终点支撑,每个支撑高出土地0。相邻支撑以直钢段连接,显然各点须在地面之上。

节俭的 FR 想最少建支撑。他勘测缆车经过的 $N$ 块等大土地 $(2 \le N \le 5,000)$,记录每块整数高度 $H$ $(0 \le H \le 1,000,000,000)$。安全规定相邻支撑间距不超 $K$ 单位 $(1 \le K \le N - 1)$。每对支撑之间的钢是刚性的直线。

求最少支撑数:每段钢完全在土地之上或恰相切,相邻支撑水平间距不超 $K$,首块和末块土地都有支撑。

输入格式

  • 第 $1$ 行:两个空格分隔整数 $N$、$K$。
  • 第 $2..N+1$ 行:第 $i+1$ 行含一个整数,土地 $i$ 的高度。

输出格式

  • 第 $1$ 行:一个整数,上述条件下最少缆车支撑塔数。

样例

输入格式 1

13 4
0
1
0
2
4
6
8
6
8
8
9
11
12

输出格式 1

5

说明

FR 在1、5、7、9、13建5支撑。钢在四处与地面相切:1–5、5–7、7–9、12–13。

只在1、5、9、13建4支撑,则5–9钢在地下。在1、7、13建支撑,虽钢均在地面以上,但7、13水平距离超过4。不可能用少于5支撑且相邻水平距离不超过4。

原始题面来源:https://github.com/ivankra/acm/blob/master/usaco/MAR06/prob/gold-en.htm

题目作者:Adam Rosenfield, 2004

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.