题目地址:http://codeforces.com/contest/1119/problem/B

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
long long a[1009];
long long b[1009];
long long h;
int n;
bool cmp(int n1,int n2)
{return n1>n2;
}
int chuli(int m)
{for(int i=1;i<=m;i++)b[i]=a[i];sort(b+1,b+m+1,cmp);long long sum=h;for(int i=1;i<=m;i=i+2){sum=sum-b[i];}if(sum>=0)return 1;return 0;
}
int main()
{scanf("%d",&n);scanf("%lld",&h);for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}if(n<=2){printf("%d\n",n);return 0;}int r,l,m;l=2;r=n;while(l<=r){m=(l+r)/2;if(m>n) m=n;if(chuli(m)==1)l=m+1;else r=m-1;}printf("%d\n",r);return 0;
}

B. Alyona and a Narrow Fridge( Codeforces Global Round 2)二分相关推荐

  1. B. Alyona and a Narrow Fridge 【 思维题 】

    B. Alyona and a Narrow Fridge Codeforces Global Round 2 &:这题看到了一种很简单的做法,于是按照敲一波,比原来打的好看多了. 题意:给你 ...

  2. Codeforces Global Round 2(CF1119)

    这场题目设置有点问题啊,难度:Div.2 A->Div.2 B->Div.2 D->Div.2 C->Div.2 D->Div.1 D-> Div.1 E-> ...

  3. Codeforces Global Round 1 晕阙记

    Codeforces Global Round 1 晕阙记 我做这场比赛的时候晕得要死.做这三道题做太久了,rating涨不起来啊! A 如果愿意的话你可以看做是膜2意义下的运算,写快速幂等各种膜运算 ...

  4. Codeforces Global Round 3

    Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...

  5. Codeforces Global Round 14 F. Phoenix and Earthquake 思维 + 并查集

    传送门 文章目录 题意: 思路: 题意: 给你nnn个点,mmm条边,限制xxx,每个点都有沥青aia_iai​,定义合并两个点即两点之间有边且au+av≥xa_u+a_v\ge xau​+av​≥x ...

  6. Codeforces Global Round 1

    Codeforces Global Round 1 题解:The Editorial of the First Codeforces Global Round A:其实mod 2计算一下就行了 B:删 ...

  7. 【Codeforces Global Round 23】B. Rebellion

    Codeforces Global Round 23中B. Rebellion Codeforces比赛记录 文章目录 题目链接: 一.B. Rebellion 题目意思: 上思路: 总结 B. Re ...

  8. Codeforces Global Round 4-D. Prime Graph(伯特兰-切比雪夫定理)

    题目:Codeforces Global Round 4-D. Prime Graph 题意:给出n(顶点的个数),要求所得图满足: 1.无平行边和自环 2.边的总数是个质数 3.每个点的度(也就是点 ...

  9. codeforces global round 23

    constest :codeforces global round 23 contest time:2022.10.16 contest grade: 2800 contest rating chan ...

最新文章

  1. @Autowired自动装配对象和new对象的区别
  2. ABAP在ALV工具栏显示一个计时器
  3. 数据结构和算法 —— 时间复杂度+空间复杂度
  4. 长期支持对OpenJDK意味着什么?
  5. 【例题5-6 UVA 540 】Team Queue
  6. php url标准化,seo优化教程:链接url标准化操作?
  7. 持续集成部署Jenkins工作笔记0008---创建用于测试的Maven工程
  8. 使用Java复制文件并在控制台显示文件进度
  9. 在HTML 页面中如何显示带圈圈的数字
  10. Python实现word转pdf
  11. 正版windows序列号被激活工具重置问题解决
  12. 我的创作纪念日(128天)
  13. linux机械硬盘提速,这方法让机械硬盘秒变固态硬盘:速度爆表
  14. 基于张量的多元多阶马尔科夫多模态预测方法
  15. arduino loar_采用ESP8266和Arduino设计基于IoT的患者健康监测系统
  16. Arcgis加载shp文件
  17. C++图书馆管理系统 详细代码
  18. 【掘金使用技巧8】用掘金编写常用技术指标
  19. uni-app实战之社区交友APP(15)聊天功能开发和后端API部署
  20. bootstrap 按钮样式大全

热门文章

  1. 安装了vmware tools还是不能复制粘贴,使用了很多种方法都不可以
  2. Virtualbox centos虚拟机网络互联总结
  3. 艺赛旗RPA 第三方库系列(二):提升 pip 工具的下载速度
  4. OpenSSL心脏出血漏洞
  5. spring cloud是什么时候流行的_老司机给我们解读 Spring Boot 最流行的 16 条实践 - 码农突围
  6. 阿龙的学习笔记---计算机网络知识点总结---三、数据链路层
  7. 【问题解决】关于Oracle官网下载JDK需要登录Oracle账户问题
  8. Sixth season seventh episode,Phoebe‘s running style is so free!!!
  9. 埃斯顿机器人 王杰高_卓越工程师讲坛——南京埃斯顿机器人工程有限公司总经理王杰高博士做客我校新年首期卓越工程师讲坛...
  10. 曾经写过得太监小说4《无名》