Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)C. Voltage Keepsake
题目链接:C. Voltage Keepsake
题解:二分时间,然后判断看需要充电的时间总和是否在允许的范围内
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define PI 3.14159265
#define eps 1e-7
using namespace std;
const int maxn=1e5+5;
int n,tmp1,p;
int a[maxn],b[maxn];
bool judge(double t)
{double q=0.0;for(int i=0;i<n;i++){if(a[i]*t>b[i]){q+=(a[i]*t-b[i])/p;}}return q<=t;
}
int main()
{std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin>>n>>p;ll sum=0;for(int i=0;i<n;i++){cin>>a[i]>>b[i];sum+=a[i];}if(p>=sum){cout<<-1<<'\n';return 0;}double l=0.0,r=1e13+7;while(r-l>eps){double mid=(r+l)/2;if(judge(mid)){l=mid;}else{r=mid;} }cout<<(l+r)/2<<endl;return 0;}
转载于:https://www.cnblogs.com/lhclqslove/p/7710618.html
Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)C. Voltage Keepsake相关推荐
- Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3)
点击打开A题链接 #include<bits/stdc++.h> using namespace std; const int MAX = 105; int n,s;int h[MAX], ...
- Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)B. Primal Sport
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)切题报告(A-B题)
这是我第二次参加CF比赛,也是第一次写博客,写得不好,望各位大佬海涵. A. Single Wildcard Pattern Matching 原题链接 这道题,这是难到让人无法直视,太水了. 题目大 ...
- Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...
- Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) A-F全题解
Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 文章目录 A. Simply Strange Sort B. ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
A. Doggo Recoloring ps:注意 n == 1 B. Weakened Common Divisor 题解:WCD出现中的数必然是 < a, b >中某个数的公约数.而 ...
- Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimination Round, Engine) C. Restoring
C. Restoring Permutation time limit per test1 second memory limit per test256 megabytes inputstandar ...
- Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimination Round, Engine) A Dead Pixel
讨论坏点的左右上下的矩形大小. #include <bits/stdc++.h> using namespace std; int main() {int t;cin >> t ...
- Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)
今天看不下去数电vp一场div2,搞A搞了很长时间,导致后面没有时间写,不过今天补题的时候全是独立补出来的没有看题解 vp3题,补3题 A - Kids Seating 最开始想的是与质数有关,乱七八 ...
最新文章
- Re-ID新方法VPM
- Spring Boot文档阅读笔记-对Messaging with RabbitMQ解析
- 多进程服务器(python 版)
- tidyr | 对数据框分行或分列进行嵌套操作
- 是==和!=相互依赖?
- vuex单一状态树_Vuex中的State
- CAD迷你看图 for Mac(强大的cad看图软件)
- 冯诺依曼体系结构_存算一体:突破冯诺依曼架构瓶颈的希望?
- win10重置网络命令_重置网络:Win10重置网络的技巧
- 谈一谈手游的运营与推广的那些事儿!
- 力扣刷题 DAY_76 贪心
- 介绍一个产品的思维导图_产品经理可以用思维导图做什么?
- rust语言与go语言_用户调查显示,Rust语言很难学习和使用
- 如何在iPhone应用中避免内存泄露
- 用 Python 绘制 XMind 思维导图
- 畅邮(DM Pro)-一款强悍、纯净而稳定的重量级电子邮箱客户端(支持分发、追踪)...
- 如何计算虚拟化vcpu_虚拟化中虚拟机处理器核数与物理主机cpu的关系
- 计算机专业在创新方面的表现,计算机专业本科论文
- iphonex时间显示蓝色_一文了解显示技术的发展简史
- Mac Dropbox 点击“首选项”无反应 没反应怎么办?
热门文章
- Windows Mobile 系列文章索引---不断整理中(2009-07-08)
- 使用MyEclipse建立working set
- 股东痛斥联想管理层:都是帅哥 但业绩差
- redis和memcache的对比
- StringBuffer类的功能
- 【hihocoder 1039 字符串消除】模拟
- 很经典的独白,搞网络的童鞋们,你们懂得
- 使用正则表达式获取连接字符串某项的值
- 西门子1200如何与c语言通信,S7-1200PLC1214c dc/dc/dc通过profinet以太网和S7-200smartcpu通讯怎么设置?...
- vm 和 容器对比_您将VM放在我的容器中