CF191B.Demonstration

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares.

Bertown has n squares, numbered from 1 to n, they are numbered in the order of increasing distance between them and the city center. That is, square number 1 is central, and square number n is the farthest from the center. Naturally, the opposition wants to hold a meeting as close to the city center as possible (that is, they want an square with the minimum number).

There are exactly k (k < n) days left before the demonstration. Now all squares are free. But the Bertown city administration never sleeps, and the approval of an application for the demonstration threatens to become a very complex process. The process of approval lasts several days, but every day the following procedure takes place:

  • The opposition shall apply to hold a demonstration at a free square (the one which isn't used by the administration).
  • The administration tries to move the demonstration to the worst free square left. To do this, the administration organizes some long-term activities on the square, which is specified in the application of opposition. In other words, the administration starts using the square and it is no longer free. Then the administration proposes to move the opposition demonstration to the worst free square. If the opposition has applied for the worst free square then request is accepted and administration doesn't spend money. If the administration does not have enough money to organize an event on the square in question, the opposition's application is accepted. If administration doesn't have enough money to organize activity, then rest of administration's money spends and application is accepted
  • If the application is not accepted, then the opposition can agree to the administration's proposal (that is, take the worst free square), or withdraw the current application and submit another one the next day. If there are no more days left before the meeting, the opposition has no choice but to agree to the proposal of City Hall. If application is accepted opposition can reject it. It means than opposition still can submit more applications later, but square remains free.

In order to organize an event on the square i, the administration needs to spend a__i bourles. Because of the crisis the administration has only b bourles to confront the opposition. What is the best square that the opposition can take, if the administration will keep trying to occupy the square in question each time? Note that the administration's actions always depend only on the actions of the opposition.

在贝尔兰德首都伯特城(Bertown),民众正举行示威活动,抗议最近贝尔兰德国王的选举结果。由奥瓦尔尼先生(Mr. Ovalny)领导的贝尔兰德反对派认为此次选举不够公正,希望在某一个广场上组织一场示威活动。

伯特城共有 nn 个广场,编号为 11 至 nn,编号顺序按其到城市中心的距离递增排列。即:编号为 11 的广场位于市中心,编号为 nn 的广场离市中心最远。显然,反对派希望将集会地点尽可能靠近城市中心(即选择编号最小的广场)。

距离示威活动开始还有恰好 kk 天(k<nk < n)。目前所有广场均空闲。但伯特城政府从不休息,审批示威申请的过程可能变得极为复杂。该审批过程将持续若干天,而每天发生如下流程:

  • 反对派须向一个当前空闲的广场(即尚未被政府占用的广场)提交示威申请;
  • 政府则试图将示威活动“转移”至剩余空闲广场中最差的一个(即编号最大的那个)。为此,政府会在反对派所申请的那个广场上启动某项长期活动——换言之,政府立即占用该广场,使其不再空闲;随后,政府提议将反对派的示威活动改至当前所有空闲广场中编号最大者(即“最差”的空闲广场)。
    • 若反对派恰好申请的就是当前最差的空闲广场,则该申请被直接接受,且政府无需花费任何资金;
    • 若政府没有足够资金在反对派所申请的广场 ii 上组织活动(即所需资金 aia_i 超出政府剩余资金),则该申请被接受;
    • 若政府虽资金不足,但仍会耗尽全部剩余资金,然后接受该申请;
  • 若申请未被接受,则反对派可选择:
    • 接受政府的提议(即改在当前最差的空闲广场举行示威),或
    • 撤回本次申请,并于次日重新提交另一份申请。
      若示威开始前已无剩余天数,则反对派别无选择,只能接受市政府的提议。
      若申请被接受,反对派仍可拒绝该结果——这意味着他们之后仍可继续提交新申请,但该广场保持空闲状态。

在广场 ii 上组织活动需花费 aia_i 伯尔(bourles)。由于财政危机,政府仅拥有总额为 bb 伯尔的资金来应对反对派。若政府每次都竭力占据反对派所申请的广场,那么反对派最终所能获得的最优(即编号最小)广场编号是多少?
注意:政府的所有行动完全取决于反对派的行动。

输入格式

The first line contains two integers n and k — the number of squares and days left before the meeting, correspondingly (1 ≤ k < n ≤ 105).

The second line contains a single integer b — the number of bourles the administration has (1 ≤ b ≤ 1018).

The third line contains n space-separated integers a__i — the sum of money, needed to organise an event on square i (1 ≤ a__i ≤ 109).

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

第一行包含两个整数 nn 和 kk —— 分别表示广场的数量以及会议召开前剩余的天数(1 ≤ k < n ≤ 1051 ≤ k < n ≤ 10^5)。

第二行包含一个整数 bb —— 表示管理部门拥有的布尔列(bourles)数量(1 ≤ b ≤ 10181 ≤ b ≤ 10^{18})。

第三行包含 nn 个用空格分隔的整数 aia_i —— 表示在第 ii 个广场举办活动所需的经费(1 ≤ ai ≤ 1091 ≤ a_i ≤ 10^9)。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin、cout 流,或 %I64d 说明符。

输出格式

Print a single number — the minimum number of the square where the opposition can organize the demonstration.

输出一个整数——反对派可以组织示威活动的编号最小的广场。

输入输出样例

  • 输入#1

    5 2
    8
    2 4 5 3 1

    输出#1

    2
  • 输入#2

    5 2
    8
    3 2 4 1 5

    输出#2

    5
  • 输入#3

    5 4
    1000000000000000
    5 4 3 2 1

    输出#3

    5

说明/提示

In the first sample the opposition can act like this. On day one it applies for square 3. The administration has to organize an event there and end up with 3 bourles. If on the second day the opposition applies for square 2, the administration won't have the money to intervene.

In the second sample the opposition has only the chance for the last square. If its first move occupies one of the first four squares, the administration is left with at least 4 bourles, which means that next day it can use its next move to move the opposition from any square to the last one.

In the third sample administration has a lot of money, so opposition can occupy only last square.

在第一个样例中,反对派可以这样行动:第一天,反对派申请第 3 号方格,政府必须在此举办活动,最终仅剩 3 博尔勒(bourles)。若第二天反对派申请第 2 号方格,则政府将没有足够资金进行干预。

在第二个样例中,反对派唯一可行的选择是最后一号方格。若其第一步占据前四个方格中的任意一个,则政府将至少剩余 4 博尔勒,这意味着第二天政府可利用其下一步行动,将反对派从任意方格驱逐至最后一号方格。

在第三个样例中,政府资金充裕,因此反对派只能占据最后一号方格。

输入解题思路,AI测评打分。不知道怎么写?

首页