QOJ.ac

QOJ

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

#22430. Bobfahren

Statistics

Bessie fährt Bob und hofft auf Gewichtsvorteile auf $L$ Metern ($2 \le L \le 1,000,000,000$).

Starttempo ist $1$ m/s; unterwegs kann sie es ändern. Nahe der Mitte jedes Meters kann Schwerkraft um $1$ m/s beschleunigen oder Bremsen das Tempo halten oder um $1$ m/s reduzieren.

Bergab gibt es $N$ ($1 \le N \le 100,000$) Kurven. Kurve $i$ liegt $T_{i}$ Meter vom Start ($1 \le T_{i} \le L-1$); in diesen Meter muss sie mit höchstens $S_{i}$ m/s eintreten ($1 \le S_{i} \le 1,000,000,000$). Im Ziel ist jedes Tempo erlaubt.

Finde das höchste erreichbare Tempo ohne Verletzung der Kurvenlimits.

Ganze Zahlen sind Metermarken, Klammern Limits, etwa $[3]$:

|   1   2   3   4   5   6   7[3]
|---+---+---+---+---+---+---+
|                            \
Start                         + 8    
                               \
                                + 9    
                                 \
                                  + 10       +++ 14 (Ziel)
                                   \         /
                              11[1] +---+---+
                                        12  13[8]

Die Tabelle zeigt Tempo am Anfang jedes Meters:

| Limit | | | | | | | | $3$ | | | | $1$ | | $8$ | | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Meter | $0$ | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | $7$ | $8$ | $9$ | $10$ | $11$ | $12$ | $13$ | $14$ | | Tempo | $1$ | $2$ | $3$ | $4$ | $5$ | $5$ | $4$ | $3$ | $4$ | $3$ | $2$ | $1$ | $2$ | $3$ | $4$ |

Maximal $5$ nahe dem Anfang von Meter $4$.

Eingabe

  • Zeile $1$: ganze Zahlen $L$, $N$ mit Leerzeichen.

  • Zeilen $2..N+1$: Zeile $i+1$ beschreibt Kurve $i$ durch ganze Zahlen $T_{i}$, $S_{i}$ mit Leerzeichen.

Ausgabe

  • Zeile $1$: ganze Zahl, höchstes Tempo von Start bis Ziel einschließlich beider.

Beispiele

Eingabe 1

14 3
7 3
11 1
13 8

Ausgabe 1

5

Aufgabenautor: Brian Jacokes, 2009

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.