Lemmings

题目连接:

http://codeforces.com/contest/163/problem/B

Descriptionww.co

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 2h 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 vi meters per minute and its weight mi. 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 mi jumps from ledge i, and a lemming of weight mj jumps from ledge j (for i < j), then the inequation mi ≤ mj 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.

Input

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 m1, m2, ..., mn (1 ≤ mi ≤ 109), where mi is the weight of i-th lemming.

The third line contains n space-separated integers v1, v2, ..., vn (1 ≤ vi ≤ 109), where vi is the speed of i-th lemming.

Output

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

Sample Input

5 3 2

1 2 3 2 1

1 2 1 2 10

Sample Output

5 2 4

Hint

题意

给你n个袋鼠,然后袋鼠要跳楼梯,你需要选出k个袋鼠出来,跳k个楼梯

第一个楼梯的高度为h,第二个为2h,第三个为3h,第n个为nh

每个袋鼠有两个属性,体重和速度,要求如果i的体重大于j的话,i只能跳比j高的楼梯

你需要使得k个袋鼠跳的最慢的袋鼠的时间最小,然后让你把方案输出

题解:

二分最后的时间,然后贪心的去选就好了

袋鼠按照体重为第一关键字,速度第二关键字从小到大排序

贪心去选

注意:精度有毒,最好就不要用eps这玩意儿。。

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
pair<pair<int,int>,int>p[maxn];
int ans[maxn];
int n,k,h;
int check(double x)
{
int tot = 1;
for(int i=1;i<=n;i++)
{
if(1.0*tot*h<=p[i].first.second*x)
{
ans[tot]=p[i].second;
tot++;
if(tot>k)return 1;
}
}
return 0;
}
int main()
{
scanf("%d%d%d",&n,&k,&h);
for(int i=1;i<=n;i++)
scanf("%d",&p[i].first.first);
for(int i=1;i<=n;i++)
scanf("%d",&p[i].first.second);
for(int i=1;i<=n;i++)
p[i].second=i;
sort(p+1,p+1+n);
double l = 0.0,r = 1000000000.0;
for(int i=1;i<=100;i++)
{
double mid = (l+r)/2.0;
if(check(mid))r=mid;
else l=mid;
}
check(r);
for(int i=1;i<=k;i++)
printf("%d ",ans[i]);
printf("\n");
}

CodeForces 163B Lemmings 二分的更多相关文章

  1. CodeForces - 163B Lemmings

    B. Lemmings time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...

  2. codeforces 1165F1/F2 二分好题

    Codeforces 1165F1/F2 二分好题 传送门:https://codeforces.com/contest/1165/problem/F2 题意: 有n种物品,你对于第i个物品,你需要买 ...

  3. codeforces 732D(二分)

    题目链接:http://codeforces.com/contest/732/problem/D 题意:有m门需要过的课程,n天的时间可以选择复习.考试(如果的d[i]为0则只能复习),一门课至少要复 ...

  4. CodeForces 359D (数论+二分+ST算法)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=47319 题目大意:给定一个序列,要求确定一个子序列,①使得该子序 ...

  5. CodeForces - 589A(二分+贪心)

    题目链接:http://codeforces.com/problemset/problem/589/F 题目大意:一位美食家进入宴会厅,厨师为客人提供了n道菜.美食家知道时间表:每个菜肴都将供应. 对 ...

  6. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  7. CodeForces - 1059D(二分+误差)

    链接:CodeForces - 1059D 题意:给出笛卡尔坐标系上 n 个点,求与 x 轴相切且覆盖了所有给出点的圆的最小半径. 题解:二分半径即可.判断:假设当前二分到的半径是 R ,因为要和 x ...

  8. Letters CodeForces - 978C (二分)

    Time limit4000 ms Memory limit262144 kB There are nn dormitories in Berland State University, they a ...

  9. Codeforces 475D 题解(二分查找+ST表)

    题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q ...

随机推荐

  1. selenium + python 自动化测试环境搭建

    selenium + python 自动化测试 —— 环境搭建 关于 selenium Selenium 是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操 ...

  2. C++将string转化成字符串数组

    //str为需要截断的string,pattern为分隔符 std::vector<std::string> split(std::string str,std::string patte ...

  3. 用python3破解wingIDE

    值得注意的是,python2的整除/在python3中变成了//,sha方法细化成了sha1和sha256,所以破解文件需要更改加密方式和整除部分的编码方式,经过修改后,这个文件可以完美演算出破解码, ...

  4. Python超级程序员使用的开发工具

    我以个人的身份采访了几个顶尖的Python程序员,问了他们以下5个简单的问题: 当前你的主要开发任务是什么? 你在项目中使用的电脑是怎样的? 你使用什么IDE开发? 你将来的计划是什么? 有什么给Py ...

  5. Module ngx_http_index_module nginx的首页模块

    Example Configuration:例子配置文件Directives 指令     index  首页 The ngx_http_index_module module processes r ...

  6. R工作空间

    工作空间,指的是你现有的R语言工作环境,它包括了任何一个用户定义的对象,比如:向量,矩阵,数据结构,列表,方法等.在一个R会话结束的时候,你可以保存现有的工作空间的映像,在下一次R启动的时候,该工作空 ...

  7. TortoiseGit's Settings

    将鼠标停放在Settings-TortoiseGit窗体上的editbox,checkbox上,有些会弹出有用的提示信息. 2.35.1. General settings: 设定自己偏好的语言,Gi ...

  8. String - 兴趣解读

    个优点: . 以下代码的HashCode是否相同,它们是否是同个对象: . 以下代码的HashCode是否相同,他们是否是同个对象:        . 以下代码的HashCode是否相同,他们是否是同 ...

  9. 测试peerdroid示例程序步骤

    来自JXTA交流群(36855950)...韦发改(992611244)  15:12:25—————————————————————————————————————————————————————— ...

  10. Oracle Standby Database 实现方案

    Oracle Standby Database 实现方案  From: http://wanow.blog.hexun.com/4672755_d.html 字号:大 中 小 版本:V20060328 ...