HDU_3486_Interviewe
Interviewe
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7561 Accepted Submission(s): 1805
YaoYao decides to make the interview as follows. First he queues the interviewees according to their coming order. Then he cuts the queue into m segments. The length of each segment is , which means he ignores the rest interviewees (poor guys because they comes late). Then, each segment is assigned to an interviewer and the interviewer chooses the best one from them as the employee.
YaoYao’s idea seems to be wonderful, but he meets another problem. He values the ability of the ith arrived interviewee as a number from 0 to 1000. Of course, the better one is, the higher ability value one has. He wants his employees good enough, so the sum of the ability values of his employees must exceed his target k (exceed means strictly large than). On the other hand, he wants to employ as less people as possible because of the high salary nowadays. Could you help him to find the smallest m?
In the first line of each case, there are two numbers n and k, indicating the number of the original people and the sum of the ability values of employees YaoYao wants to hire (n≤200000, k≤1000000000). In the second line, there are n numbers v1, v2, …, vn (each number is between 0 and 1000), indicating the ability value of each arrived interviewee respectively.
The input ends up with two negative numbers, which should not be processed as a case.
7 100 7 101 100 100 9 100 100 110 110
-1 -1
We need 3 interviewers to help YaoYao. The first one interviews people from 1 to 3, the second interviews people from 4 to 6,
and the third interviews people from 7 to 9. And the people left will be ignored. And the total value you can get is 100+101+100=301>300.
- n个人挑m个人并要求m个人的属性达到最低标准,求min(m)
- 二分呗,然后区间max,记录ans
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long LL ;
typedef unsigned long long ULL ;
const int maxn = 2e5 + ;
const int inf = 0x3f3f3f3f ;
const int npos = - ;
const int mod = 1e9 + ;
const int mxx = + ;
const double eps = 1e- ;
const double PI = acos(-1.0) ; int n, limit, fac[], dp[maxn][], ans;
int main(){
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
for(int i=;i<;i++)
fac[i]=(<<i);
while(~scanf("%d %d",&n,&limit)){
if(n< && limit<){
break;
}
for(int i=;i<=n;i++)
scanf("%d",&dp[i][]);
int k=(int)(log((double)n)/log(2.0));
for(int j=;j<=k;j++)
for(int i=;i+fac[j]-<=n;i++)
dp[i][j]=max(dp[i][j-],dp[i+fac[j-]][j-]);
int l=, r=n;
ans=-;
while(l<=r){
int m=(l+r)>>;
int sum=, len=n/m;
k=(int)(log((double)len)/log(2.0));
for(int i=;i<=m;i++){
int u=(i-)*len+, v=i*len;
sum+=max(dp[u][k],dp[v-fac[k]+][k]);
}
// printf("[%d] sum=%d\n",m,sum);
if(sum>limit){
ans=m;
r=m-;
}else{
l=m+;
}
}
printf("%d\n",ans);
}
return ;
}
HDU_3486_Interviewe的更多相关文章
随机推荐
- CentOS 7 Minimal编译安装MySQL5.6
写在前面,编译安装MySQL的优势:平台无关.可设定参数按需安装.安装的MySQL目录独立(方便清楚).更好的平台耦合及运行性能(很多运维的观点):缺点:编译安装较慢. 一.撤换系统防火墙 注:Cen ...
- 当点击onBackpress方法或者onKeyDown方法时出现不能响应的问题解决办法
一般来讲,当我们点击手机上的back键之后,会直接调用activity的onbackpress()方法,或者我们也可以通过这样来进行捕捉点击事件 @Override public boolean on ...
- Unity简介
Unity (也称 nity3D) 是一套包括图形. 声音.物理等功能的游戏引擎,提供了一个强大的关卡编辑器,支持大部分主流 3D 软件格式,使用 C# JavaScript 等高级语言实现脚本功能, ...
- HDU 4497 GCD and LCM (分解质因数)
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=4497 假设G不是L的约数 就不可能找到三个数. L的全部素因子一定包括G的全部素因子 而且次方数 ...
- POJ 1141 Brackets Sequence(区间DP, DP打印路径)
Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...
- 2011年冬斯坦福大学公开课 iOS应用开发教程学习笔记(第三课)
第二课名称是:Objective-C 回顾上节课的内容: 创建了单个MVC模式的项目 显示项目的各个文件,显示或隐藏导航,Assistant Editor, Console, Object Libra ...
- ThreadUtil 多线程处理List,回调处理具体的任务
每次想多线程处理一个大的结果集的时候 都需要写一大堆代码,自己写了个工具类 方便使用 package com.guige.fss.common.util; import com.guige.fss.c ...
- 《C#高级编程》学习笔记------抗变和协变
1.协变和抗变 在.NET 4之前,泛型接口是不变的..NET 4通过协变和抗变为泛型接口和泛型委托添加了一个重要的扩展.协变和抗变指对参数和返回值的类型进行转换.例如,可以给一个需要Shape参数的 ...
- sql数据库中如何根据身份证号判断性别
身份证号有15位和18位的..在sql中该如何判断? I_sex ,) ,) then '男' else '女' END
- 布局的诡异bug合集+解决方法(更新中)
1.元素内部子元素的margin的边界线基准点的问题 论如何生硬起名字!!我反正已经被自己总结的题目绕晕了... “演员”介绍: 外层父元素:蓝色边框: 内部子元素:绿色区域: 粉红色区域是元素内部绿 ...