当前位置:网站首页>VK Cup 2017 - Round 2 A. Voltage Keepsake
VK Cup 2017 - Round 2 A. Voltage Keepsake
2022-06-09 05:56:00 【No toast】
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
using namespace std;
#define X first
#define Y second
#define eps 1e-6
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
const int N = 1e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
#define int long long
int n,p,x[N],y[N];
inline bool check(double X){
double nd=0;
for(int i=1;i<=n;i++){
if(y[i]*1.0/x[i]>=X) continue;
nd+=(x[i]*X-y[i])/p;
}
if(X-nd>=eps) return 1;
else return 0;
}
void solve(){
scanf("%lld%lld",&n,&p);
int sum=0;
for(int i=1;i<=n;i++) scanf("%lld%lld",&x[i],&y[i]),sum+=x[i];
if(p-sum>=0){
cout<<-1<<endl;
return ;
}
double l=0,r=1e10;
while(r-l>eps){
double mid=(l+r)/2.0;
if(check(mid)){
l=mid;
}else r=mid-eps;
}
double R=1e10;
if(fabs(l-R)<=eps){
cout<<-1<<endl;
}else printf("%0.4lf\n", l);
return;
}
int32_t main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
猜你喜欢

MySql中事务详细理解学习(事务管理、事务隔离级别、事务传播机制)

Quelles sont les informations contenues dans le certificat SSL?
![Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)](/img/e8/d11adffb784b0875c69f6fe5a32b63.png)
Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)

Heqibao's trip to Chongqing ~

【论文】CBAM: Convolutional Block Attention Module

MVCC多版本控制

Wireshark图解TCP三次握手与四次挥手

Gstreamer应用开发实战指南(三)

In latex, \cdots is followed by a sentence. What's wrong with the format of the following sentence.

Here comes the era of metaltc2.0
随机推荐
VK Cup 2017 - Round 3 B. Dynamic Problem Scoring
Easyexcel export, self encapsulating header and sequence
Record rsyslog lost logs
JVM basic theory.
IP地址的分配原理
On input function of istream input stream object CIN
synchronized 详细解析
Ffmpeg pulls webrtc streams, and the first all open source solution in the metartc industry is coming
Time stamp verification code signing method for code signing certificate
About the problem of code wrapping when formatting code with vscode
Entity to map tool
VK Cup 2017 - Round 1 C. Bear and Tree Jumps 换根dp
输入两个正整数m和n,求其最大公约数和最小公倍数。
Three queues CXQ, entrylist, waitset personal understanding analysis
DTD的概念及编写
New and old versions of Minio tool classes and deployment documents
DBeaver导出查询数据sql文件
圖像處理-特征融合相關延伸
Tricks | [trick6] learning rate adjustment strategy of yolov5 (one cycle policy, cosine annealing, etc.)
【论文】CBAM: Convolutional Block Attention Module