CF163B.Lemmings

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

As you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at the height of h meters, the second one is at the height of 2_h_ meters, and so on (the i-th ledge is at the height of i·h meters). The lemmings are going to jump at sunset, and there's not much time left.

Each lemming is characterized by its climbing speed of v__i meters per minute and its weight m__i. This means that the i-th lemming can climb to the j-th ledge in minutes.

To make the jump beautiful, heavier lemmings should jump from higher ledges: if a lemming of weight m__i jumps from ledge i, and a lemming of weight m__j jumps from ledge j (for i < j), then the inequation m__i ≤ m__j should be fulfilled.

Since there are n lemmings and only k ledges (k ≤ n), the k lemmings that will take part in the jump need to be chosen. The chosen lemmings should be distributed on the ledges from 1 to k, one lemming per ledge. The lemmings are to be arranged in the order of non-decreasing weight with the increasing height of the ledge. In addition, each lemming should have enough time to get to his ledge, that is, the time of his climb should not exceed t minutes. The lemmings climb to their ledges all at the same time and they do not interfere with each other.

Find the way to arrange the lemmings' jump so that time t is minimized.

众所周知,旅鼠喜欢跳跃。为了下一次壮观的集体跳跃,nn 只旅鼠聚集在一块高岩石旁,岩石上共有 kk 个舒适的落脚点。第一个落脚点位于 hh 米高度处,第二个落脚点位于 2h2h 米高度处,依此类推(第 ii 个落脚点位于 i⋅hi \cdot h 米高度处)。旅鼠们将在日落时分跳跃,而留给它们的时间已所剩无几。

每只旅鼠由其攀爬速度 viv_i(单位:米/分钟)和体重 mim_i 所刻画。这意味着第 ii 只旅鼠攀爬至第 jj 个落脚点所需时间为 分钟。

为使跳跃显得优美,较重的旅鼠应从更高的落脚点起跳:若一只体重为 mim_i 的旅鼠从第 ii 个落脚点起跳,另一只体重为 mjm_j 的旅鼠从第 jj 个落脚点起跳(其中 i<ji < j),则必须满足不等式 mi≤mjm_i \le m_j。

由于共有 nn 只旅鼠,但仅有 kk 个落脚点(且 k≤nk \le n),因此需从中选出 kk 只旅鼠参与跳跃。被选中的旅鼠须被分配至第 11 至第 kk 个落脚点,每个落脚点恰好安排一只旅鼠。旅鼠应按落脚点高度递增的顺序,以体重非递减的方式进行排列。此外,每只旅鼠必须有足够时间抵达其指定落脚点,即其攀爬耗时不得超过 tt 分钟。所有旅鼠同时开始攀爬,且互不干扰。

请找出一种安排旅鼠跳跃的方式,使得时间 tt 最小化。

输入格式

The first line contains space-separated integers n, k and h (1 ≤ k ≤ n ≤ 105, 1 ≤ h ≤ 104) — the total number of lemmings, the number of ledges and the distance between adjacent ledges.

The second line contains n space-separated integers _m_1, _m_2, ..., m__n (1 ≤ m__i ≤ 109), where m__i is the weight of i-th lemming.

The third line contains n space-separated integers _v_1, _v_2, ..., v__n (1 ≤ v__i ≤ 109), where v__i is the speed of i-th lemming.

第一行包含三个以空格分隔的整数 nn、kk 和 hh(1 ≤ k ≤ n ≤ 1051 \le k \le n \le 10^5,1 ≤ h ≤ 1041 \le h \le 10^4)—— 分别表示旅鼠的总数、平台的数量以及相邻平台之间的距离。

第二行包含 nn 个以空格分隔的整数 m1, m2, ..., mnm_1,\,m_2,\,...,\,m_n(1 ≤ mi ≤ 1091 \le m_i \le 10^9),其中 mim_i 表示第 ii 只旅鼠的重量。

第三行包含 nn 个以空格分隔的整数 v1, v2, ..., vnv_1,\,v_2,\,...,\,v_n(1 ≤ vi ≤ 1091 \le v_i \le 10^9),其中 viv_i 表示第 ii 只旅鼠的速度。

输出格式

Print k different numbers from 1 to n — the numbers of the lemmings who go to ledges at heights h, 2_h_, ..., kh, correspondingly, if the jump is organized in an optimal way. If there are multiple ways to select the lemmings, pick any of them.

从 1 到 n 中输出 k 个互不相同的数——这些数分别对应在最优跳跃方案下,跳向高度为 h, 2_h_, ..., kh 的悬崖的旅鼠编号。若存在多种选择旅鼠的方式,任选其一即可。

输入输出样例

  • 输入#1

    5 3 2
    1 2 3 2 1
    1 2 1 2 10

    输出#1

    5 2 4
  • 输入#2

    5 3 10
    3 4 3 2 1
    5 4 3 2 1

    输出#2

    4 3 1

说明/提示

Let's consider the first sample case. The fifth lemming (speed 10) gets to the ledge at height 2 in minutes; the second lemming (speed 2) gets to the ledge at height 4 in 2 minutes; the fourth lemming (speed 2) gets to the ledge at height 6 in 3 minutes. All lemmings manage to occupy their positions in 3 minutes.

我们考虑第一个样例。第五只旅鼠(速度为 10)在 分钟后到达高度为 2 的平台;第二只旅鼠(速度为 2)在 2 分钟后到达高度为 4 的平台;第四只旅鼠(速度为 2)在 3 分钟后到达高度为 6 的平台。所有旅鼠均能在 3 分钟内占据各自的位置。

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

首页