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. mybatis3-generator-plugin插件地址

    http://repo1.maven.org/maven2/com/github/oceanc/mybatis3-generator-plugin/0.4.0/

  2. Linux操作系统以及各大发行版介绍——Linux operating system and major distribution is introduced

    什么是Linux? 也许很多人会不屑的说,Linux不就是个操作系统么.错!Linux不是一个操作系统,严格来讲,Linux只是一个操作系统中的内核.内核是什么?内核建立了计算机软件与硬件之间通讯的平 ...

  3. [置顶] 【Git入门之九】解决冲突

    原创作品,转载请标明:http://blog.csdn.net/jackystudio/article/details/12309531 1.多人协作冲突 如果多人同时修改了同一个文件,那会出现什么样 ...

  4. 关于C#泛型列表List<T>的基本用法总结

    //示例代码如下:using System;using System.Collections.Generic;using System.Collections.ObjectModel;namespac ...

  5. SOAP详解

    1. SOAP简介 1.1应用背景 对于应用程序开发来说,使程序之间进行因特网通信是很重要的.目前的应用程序通过使用远程过程调用(RPC)在诸如 DCOM 与 CORBA 等对象之间进行通信,但是 H ...

  6. 第1章 Python介绍

    本章将包含Python的介绍,安装以及Python的数据类型及运算符.其中关于数据类型中的字符串.列表.元组和字典后续章节会着重介绍. 1.1 为什么学Python Python是一门简明并强大的面向 ...

  7. jquery animate

    $(".logo").animate( { opacity: .25, //将不透明度逐渐变成.25 height: 0 //高度逐渐变成0 }, { duration: 1000 ...

  8. VS2008 ctrl+shift+F热键冲突

    今天发现有时VS 热键好使,有时,怎么按都没有反应. 后来发现是和输入法有冲突,把输入法快捷键改了就好了.

  9. Qt Linux 使用QJson库

    1. 下载 到http://dl.oschina.net/soft/qjson下载库源文件: qjson-0.8.1-1385961227890.zip 解压为:qjson-0.8.1 2. 编译 c ...

  10. VS中批量删除cs代码中的#region和#endregion

    Visual Studio中如何批量删除cs代码中的#region和#endregion,不删除它们中间的代码,只删除这两个标记及标记的注解的方法.Vs中提供了很强大的文本查找与替换功能,简单的替换只 ...