http://poj.org/problem?id=3232

题意:有一个含有n辆车的车队,当前距离终点的距离已知,有m个加速器,每个加速器在一个时刻只能给一辆车用,一旦使用就会使得其速度由1变成k,加速器可以重复使用,问最快所有车辆到达终点的时间。

思路:二分枚举所需的最短时间。

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 300000
#define ll long long
using namespace std; ll t,n,m,k;
ll a[maxn]; bool ok(ll c)
{
ll cnt=,x=c*m;
for(int i=; i<n; i++)
{
if(a[i]<=c) continue;
if((a[i]-c)%(k-)==)
cnt=((a[i]-c)/(k-));
else
cnt=((a[i]-c)/(k-))+;
if(cnt>c) return false;
x-=cnt;
if(x<) return false;
}
return true;
} int main()
{
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
ll max1=;
for(int i=; i<n; i++)
{
scanf("%lld",&a[i]);
max1=max(max1,a[i]);
}
scanf("%lld%lld",&m,&k);
ll l=,r=max1;
if(k==)
{
printf("%lld\n",max1);
continue;
}
int mid;
while(l<r)
{
mid=(l+r)>>;
if(ok(mid))
{
r=mid;
}
else l=mid+;
}
printf("%lld\n",l);
}
return ;
}

poj 3232 Accelerator的更多相关文章

  1. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  2. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  3. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  4. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  5. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  6. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  7. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  8. POJ 2752 Seek the Name, Seek the Fame [kmp]

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Ac ...

  9. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

随机推荐

  1. Android Develop 之 Ddevelop WorkFlow Basics

    Android应用程序的开发流程一言以蔽之,可以用一图五步概括.一图如下. 第一步:安装.安装开发环境,包括JDK,Android Studio,SDK Manager(通常下载Android Stu ...

  2. Flask 安装 Ubuntu 14.04

    学习文档: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world 中文版学习文档 开源中国版: ...

  3. Spark on YARN的两种运行模式

    Spark on YARN有两种运行模式,如下 1.yarn-cluster:适合于生产环境.        Spark的Driver运行在ApplicationMaster中,它负责向YARN Re ...

  4. jquery cycle pugin

    插件地址: http://jquery.malsup.com/cycle/ <div id="propaganda"><div id="pgdImg&q ...

  5. Android 基础组件

    基础组件 所有的控件都可以在java代码中创建出来,并且大部分的属性都对应set和get方法,比如 View view = new View(Context context)  context是上下文 ...

  6. HDU4512:吉哥系列故事——完美队形I(LICS)

    Problem Description 吉哥这几天对队形比较感兴趣. 有一天,有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成一 ...

  7. Android -- getSystemService

    Android的后台运行在很多service,它们在系统启动时被SystemServer开启,支持系统的正常工作,比如MountService监听是否有SD卡安装及移除,ClipboardServic ...

  8. exploit writing tutorial 阅读笔记总结

    近日阅读Corelan Team编写的exploit writing tutorial系列,大致了解了一下原理,记了一些笔记.此系列文章有中文翻译版,在看雪论坛上发表. 英文版地址:https://w ...

  9. 如何在苹果官网下载旧版本的Xcode 方法

    1   在百度里输入“苹果开发者中心“,进入以下页面.点击页面中的“Member Center" 2  出现登录界面.这是需要苹果开发者帐号的,没有帐号的可以选择“Create Apple ...

  10. MyEclipse汉化后问题

    今天为了教学生如何汉化MyEclipse10.7,所以讲IDE汉化了一下. 个人还是喜欢用英文版,所以就将D:\MyEclipse\MyEclipse 10目录下的配置文件myeclipse.ini里 ...