当前位置:网站首页>蓝桥杯-二分-分巧克力
蓝桥杯-二分-分巧克力
2022-07-22 11:07:00 【ai_moe】
题目详情
解题代码
#include<iostream>
using namespace std;
const int N = 1e5+10;
int n,k;
int h[N],w[N];
bool check(int mid)
{
int m=0;
for(int i=0;i<n;i++)
{
m=m+(h[i]/mid)*(w[i]/mid);
if(m>=k) return true;
}
return false;
}
int main()
{
cin >> n >>k;
for(int i=0;i<n;i++) cin >> h[i] >> w[i];
int l=1,r=1e5;
while(l<r)
{
int mid=l+r+1>>1;
if(check(mid)) l=mid;
else r=mid-1;
}
cout << l;
return 0;
}
边栏推荐
- Human stars website collection plan -- Michael kerrisk
- acwing-飞行员兄弟
- Bash basic function - input / output redirection
- Wechat applet comprehensive case practice 1
- Interview shock 67: talk about tcp/ip protocol? And the role of each layer?
- 如何做好研发精益需求管理
- Juc-7.0-thread collaboration countdownlatch
- JUC-7.2-线程协作-Condition
- Juc-8.0-future and callable
- Wechat applet introduction tutorial learning notes - layout basis of UI chapter
猜你喜欢
随机推荐
Character interception command
操场运动场室外扩声系统方案与功能分析
Bash basic functions - Multi command sequential execution and pipeline compliance
6.管理服务器和服务
Buuctf entry diary 01 -- easysql
Network Accounting - layered structure, OSI communication process, tcp/ip model and 5-layer reference model
LeetCode笔记(一)回溯
Notes d'apprentissage du système intégré
[LTTng学习之旅]------Components of LTTng 解构
Seata first met
JS BOM(浏览器对象模型)
Juc-6.2-concurrency container copyonwritearraylist
Buuctf breakthrough diary 04 -- [actf2020 freshman competition]include1
Buuctf breakthrough diary -- [geek challenge 2019] hardsql1
蓝桥杯-省赛-带分数
物理层2.1
中等专业学校校园广播系统解决方案-职业中专校园IP网络广播应用
简单句(Simple sentences)-one
[lttng learning journey] - trace control -- advanced
Bash variable -- position parameter variable