QOJ.ac

QOJ

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

#22692. 交作业

Statistics

Bessie 要交 Moo U 的 $C$ 门课作业($1 \le C \le 1{,}000$),才有时间在等回家公交时与同学反刍。

老师下课、擦黑板、收实验用品等之后才收作业。输入给出每位老师最早接收时间。

她从 $H$ 米走廊($1 \le H \le 1{,}000$)的一端(距离 $0$)开始,每秒一米,任选顺序去教室交作业。各教室及候车区门均在走廊上。

给定出口、教室位置和老师时间表,求她最早何时能从门走到公交候车区。离开前须交完全部作业,提交本身不耗时。

输入格式

  • 第 1 行:三个整数 $C$、$H$、$B$。$B$($0 \le B \le H$)为走廊入口到候车区的距离。
  • 第 $2..C+1$ 行:每行两个整数描述须交作业的教室。首个($0..H$)为距入口的米数;第二个($0..10,000$)为该课老师最早接收的秒数。

输出格式

  • 第 1 行:一个整数,最早可走过通往候车区的门的秒数。

样例

输入格式 1

4 10 3
8 9
4 21
3 16
8 12

输出格式 1

22

说明

时间 动作
$0$ Bessie 走向走廊$8$米处教室(位置$8$米)
$8$ 等$1$秒
$9$ 交第一份作业
$9$ 等$3$秒,想着夏日清凉干草
$12$ 交此处另一份作业
$12$ 走回走廊$4$米处教室(位置$4$米)
$16$ 等$5$秒,想着曾遇过的英俊公牛
$21$ 交作业
$21$ 走回走廊$1$米处教室(位置$3$米)
$22$ 交作业
$22$ 离开,这也是公交出口处

因此可在 $22$ 离开,没有更好的安排。

题目致谢:Hal Burch,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.