当前位置:网站首页>2022河南萌新联赛第(三)场:河南大学 A - 玉米大炮
2022河南萌新联赛第(三)场:河南大学 A - 玉米大炮
2022-07-26 04:29:00 【WA_自动机】
A - 玉米大炮
很容易发现答案具有单调性, 如果花费 x 的时间可以击溃目标, 则花费 x + 1 x + 1 x+1 的时间也可以击溃目标, 可以直接二分答案, 考虑到二分的左右区间在 [ 0 , 1 0 18 ] [0, 10^{18}] [0,1018], 对于 C + + 选手可能需要使用__int128 , 或者在二分的过程提前判断是否合法。
- 时间复杂度 O ( n × l o g ( 1 0 18 ) ) O(n × log(10^{18})) O(n×log(1018))
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int a[N],b[N];
int n,m;
int check(LL x)
{
LL sum=0;
for(int i=1;i<=n;i++)
{
sum+=(x/b[i]+1)*a[i];
if(sum>=m) return 1;
}
return 0;
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
LL l=0,r=1e18;
while(l<r)
{
LL mid=(l+r)>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<r<<endl;
return 0;
}
边栏推荐
- 这种是我的vs没连上数据库吗
- Recognized again | saining network security has been listed in the ccsip 2022 panorama of China's network security industry
- 理性认知教育机器人寓教于乐的辅助作用
- MapReduce中分区数与ReduceTask个数关系比较
- Apisex's exploration in the field of API and microservices
- Solution: runtimeerror: expected object of scalar type int but got scalar type double
- Page pull-up refresh and pull-down loading
- egg-ts-sequelize-CLI
- MATLAB绘图
- 3、 @requestmapping annotation
猜你喜欢

Integrated architecture of performance and cost: modular architecture

Optimization analysis and efficiency execution of MySQL

How does win11 22h2 skip networking and Microsoft account login?

YAPI安装

综合评价与决策方法

p-范数(2-范数 即 欧几里得范数)

How does win11 set the theme color of the status bar? Win11 method of setting theme color of status bar

Steam science education endows classroom teaching with creativity

What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep

SEGGER Embedded Studio找不到xxx.c或者xxx.h文件
随机推荐
Huawei issued another global convening order of "genius youth", and some people once gave up their annual salary of 3.6 million to join
YAPI安装
FFmpeg 视频添加水印
1. If function of Excel
Which websites can I visit to check the latest medical literature?
UE4 多个角色控制权的切换
Integrated architecture of performance and cost: modular architecture
Wu Enda's machine learning after class exercises - linear regression
Comprehensive evaluation and decision-making method
Yadi started to slow down after high-end
qt编译报错整理及Remote模块下载
Under the high debt of Red Star Macalline, is it eyeing new energy?
Creative design principle of youth maker Education
Sangi diagram of machine learning (for user behavior analysis)
生活相关——一个华科研究生导师的肺腑之言(主要适用于理工科)
Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
九、文件上传和下载
1. Excel的IF函数
生活相关——减少期待,更快乐
Steam科学教育赋予课堂教学的创造力