QOJ.ac

QOJ

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

#22624. Impianto di risalita

Statistics

Farmer Ron in Colorado costruisce un centro sciistico per mucche, ma il budget consente un solo impianto. La monorotaia collega supporto iniziale di cemento a quello finale tramite intermedi, ciascuno alto0 sopra il terreno. Acciaio rettilineo collega ogni coppia adiacente e deve stare ovunque sopra il suolo.

Parsimonioso, FR minimizza supporti. Misurò $N$ terreni uguali $(2 \le N \le 5,000)$ di altezza intera $H$ $(0 \le H \le 1,000,000,000)$. Sicurezza impone distanza adiacente al massimo $K$ unità $(1 \le K \le N - 1)$. Acciaio rigido forma retta.

Trova minimi supporti: acciaio interamente sopra o tangente al terreno, distanza orizzontale adiacente al massimo $K$, supporti su primo e ultimo terreno.

Input

  • Riga $1$: due interi separati da spazio $N$, $K$.
  • Righe $2..N+1$: riga $i+1$ contiene altezza intera del terreno $i$.

Output

  • Riga $1$: intero, minimo di torri sotto tali vincoli.

Esempi

Input 1

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

Output 1

5

Nota

5 supporti in1, 5, 7, 9, 13. Acciaio tangente in4 punti:1–5, 5–7, 7–9, 12–13.

4 supporti in1, 5, 9, 13 danno acciaio sotterraneo5–9. In1, 7, 13 resta sopra ma7 e13 distano oltre4 orizzontalmente. Meno di5 supporti con distanze adiacenti al massimo4 è impossibile.

Fonte originale: https://github.com/ivankra/acm/blob/master/usaco/MAR06/prob/gold-en.htm

Autore del problema: 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.