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. 解决本地软件链接不上虚拟机mysql 的问题:grant all privileges on *.* to 'root'@'%' identified by 'nsfocus'

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' ->     IDENTIFIED BY 'some_pass' WITH ...

  2. Oracle常用脚本——通过RMAN配置RAC环境的分布式磁带机

    RAC的两个节点:node1,node2 RAC的两个实例:dbrac1,dbrac2 用户,密码的东西大家看看就懂了.设置成8能通道的. #!/bin/bash rman target / < ...

  3. adb 获取手机值

     获取手机RAM值    adb shell cat /proc/meminfo   获取手机内存值     adb shell df /data

  4. Linux命令之查找

    在Linux中,有非常多方法能够做到这一点.国外站点LinuxHaxor总结了五条命令,你能够看看自己知道几条.大多数程序猿,可能常常使用当中的2到3条,对这5条命令都非常熟悉的人应该是不多的. 1. ...

  5. Facebook的手游出海之道

    对于不同的游戏公司,面临的同一个问题就是怎样让海外玩家能够一眼在App中发现你,成为你的新用户:不仅如此,怎样留住这些用户,让他们成为你游戏的忠实玩家也是让全部游戏开发商困扰的一个问题. w=580& ...

  6. C++学习笔记39:进程概念

    进程的基本概念 进程是描述程序执行过程和资源共享的基本单位 主要目的:控制和协调程序的执行 进程相关函数 用户与组ID函数 创建进程:system(),fork(),exec() 终止进程:kill( ...

  7. Android Studio 安装

    准备: JDK 7以及以上版本. Android Studio安装文件  中文站下载 http://www.android-studio.org/index.php/download exe ,包含S ...

  8. [HAOI2006]聪明的猴子

    /* 找出能连通所有点的一棵树 是的最大的边最小 很显然就是最小生成树. 堆优化prim. */ #include<iostream> #include<cstring> #i ...

  9. Html.ActionLink简单用法(转)

    一 Html.ActionLink("要显示的文字","actionName") 该重载的第一个参数是该链接要显示的文字,第二个参数是对应的控制器的方法, 默认 ...

  10. hdu 1232

    以前写的.....拿出来看看.... 并查集模板: #include <iostream> #include <string> using namespace std; int ...