QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#8777. 护照印章

统计

你刚刚拿到了一本崭新的护照,页面正等待着移民局官员盖章。遗憾的是,由于你的护照页数太多,移民局官员太懒,不愿高效地利用你的页面,因此你可能比预想中更快地需要更换新护照……

你已经准备好了一些行程。对于每一次行程,当你通过护照检查时,移民局官员会寻找一些连续的、尚未盖过章的页面,并将它们全部盖上章。由于官员很懒,无法保证具体是哪几页连续的页面会被盖章。

你将按顺序进行这些行程,直到你的护照不再有足够的连续空白页面来满足下一次行程的需求,此时你将申请一本新护照。你的计划是固定的——即使跳过中间的某个行程能让你完成更多后续行程,你也不会这样做。

如果移民局官员故意与你作对,请找出第一个你可能无法出行的行程(即此时你的护照没有足够的连续空白页面),或者判断你是否总能完成所有行程而不会耗尽空白页面。

输入格式

第一行包含两个整数 $n$ ($1 \le n \le 10^5$) 和 $p$ ($1 \le p \le 10^{18}$),其中 $n$ 是你计划的行程数量,$p$ 是你新护照的页数。

接下来的 $n$ 行,每行包含一个整数 $c$ ($1 \le c \le 10^{18}$),表示该次行程需要盖章的连续页面数量。

输出格式

输出一个整数,表示在需要更换新护照(因为没有足够的连续空白页面进行下一次行程)之前,你可能完成的最少行程数。如果你在最坏的情况下也能完成所有行程,则输出 $n$。

样例

输入 1

5 15
1
2
3
4
5

输出 1

3

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.