CodeForces 772A Voltage Keepsake】的更多相关文章

You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power store…
二分答案,验证. 二分到一个答案,比他小的时间都需要补充到这个时间,计算所需的量,然后和能提供的量进行比较. #include <cstdio> #include <cmath> #include <set> #include <cstring> #include <algorithm> #include <iostream> #include <string> #include <vector> using…
C. Voltage Keepsake 题目链接:http://codeforces.com/problemset/problem/801/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have n devices that you want to use simultaneously. The i-th dev…
题目链接:http://codeforces.com/contest/801/problem/C 题目大意:给你一些电器以及他们的功率,还有一个功率一定的充电器可以给这些电器中的任意一个充电,并且不计切换充电器的时间,问你最多能够同时使用这些充电器多久,如果可以一直用下去就返回-1.要求时间误差不能超过10^-4. 思路:开始没就见过这种类型的题目傻傻地一点一点把时间加上去....后来知道这是用了二分枚举,首先定义一个右边界(r=1e11根据提目应该大于1e10多一点)和左边界(l=0),然后不…
地址:http://codeforces.com/contest/801/problem/C 题目: C. Voltage Keepsake time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have n devices that you want to use simultaneously. The i-th devi…
C. Voltage Keepsake time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is…
C. Voltage Keepsake time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is…
[题目链接]:http://codeforces.com/contest/801/problem/C [题意] 有n个设备 你想同时使用 第i个设备每分钟消耗ai点电量,一开始有bi点电量 你有一个充电器,每分钟可以冲p点电量 问你第一次有用电器的电量耗光是在何时 [题解] 二分时间t 充电量为temp=t*p 每一个设备 now = bi-ai*t 如果 now<0 if (temp<now) return false; else temp-=now; return true; 这种小数的二…
题目链接:http://codeforces.com/contest/801/problem/C 题意:给出一个充电器每秒钟充p个点,还有n个电器要同时使用a[i]表示第i个电器每秒钟用多少点,b[i]表示第i个 原来存了都少电.充电器可以无缝切换这充电,但是只能给一个充(同一时间).最后问你最长可用多久,如果可以 无限时间的用的话,就输出-1. 题解:首先确定一下什么时候输出-1也就是可以无限充电的情况,就是p大于所有a的总和就行. 然后就是时间有限的情况.这里明确一个式子. need*t=a…
题目链接 这是一道很棒的二分题. 思路: 首先先思考什么情况下是可以无限的使用,即输出-1. 我们思考可知,如果每一秒内所有设备的用电量总和小于等于充电器每秒可以充的电,那么这一群设备就可以无限使用. 接下来分析不是无限使用的情况: 题目要求的是满足某个情况的最大值. 很像二分的类型,二分题目往往就是求某一个满足情况的最值,这样我们只需要寻找上限和下限,并对每一次mid值进行检验是否满足,这样的模型时间度一般为O(  N*Log( L )) L代表的是总区间的长度,而N代表的是完成一次判定需要的…