Codeforces Round #834 (Div. 3) E. The Humanoid

Let’s make two obvious remarks:

  1. If we can absorb two astronauts with power x≤yx≤yx≤y, then we can always first absorb an astronaut with power xxx, and then an astronaut with power yyy;
  2. If we can absorb some astronaut, it is effective for us to do it right now.
    Let’s sort the astronauts powers in increasing order.

Now let’s lock the sequence of serums we use. There are only three of them: blue serum can be the first, second or third.

Let’s absorb the astronauts in increasing order of their powers, and if we can’t, then use the next serum in a locked sequence or stop.

This solution works for O(n)O(n)O(n).

#include<bits/stdc++.h>
using namespace std;int main()
{int T;cin>>T;while(T--){int n,h;cin>>n>>h;vector<int> a(n);for(int i=0;i<n;i++) cin>>a[i];sort(a.begin(),a.end());vector<int> b{2,2,3};int mx=0;do{long long res=h;int pos=0;for(int i=0,j=0;i<n;){if(res>a[i]) res+=a[i++]/2;else if(j<3) res*=b[j++];else break;pos=i;}mx=max(mx,pos);}while(next_permutation(b.begin(),b.end()));cout<<mx<<endl;}return 0;
}

Codeforces Round #834 (Div. 3) E. The Humanoid相关推荐

  1. E. The Humanoid Codeforces Round #834 (Div. 3)(暴力dfs?)

    题意:有一个怪兽和n个宇航员(怪兽有一个绿色药丸和一个蓝色药丸),怪兽和宇航员都有自己的一个力量值,怪兽在面对力量值小于他的宇航员时可以吃了他并且获得他的的力量(向下取整),怪兽可以在任意时刻吃他的小 ...

  2. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  3. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  4. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

  5. Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...

  6. Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...

  7. Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...

  8. Codeforces Round #700 (Div. 2) D2 Painting the Array II(最通俗易懂的贪心策略讲解)看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 整场比赛的A ~ E 6题全,全部题目超高质量题解链接: Codeforces Round #700 ...

  9. Codeforces Round #699 (Div. 2) F - AB Tree(贪心、树上DP)超级清晰,良心题解,看不懂来打我 ~

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #699 (Div. 2) F - AB Tree Problem ...

最新文章

  1. 计算机网络——网络地址转换(NAT)
  2. python123期末测试第十周答案_Python语言设计_章节测验,期末考试,慕课答案查询公众号...
  3. Java绘图模式概述
  4. c# 访问修饰符的访问权限
  5. 从storyboard加载视图控制器
  6. link标签中的integrity和crossorigin字段---web前端工作笔记015
  7. 25个增强iOS应用程序性能的提示和技巧--高级篇
  8. zabbix配置微信报警
  9. 关于Angular样式封装
  10. C语言dos游戏编程,◣电脑游戏编程入门 (DOS)◥
  11. Keil MDK5的安装及破解详细步骤
  12. 项目验收的步骤和程序
  13. 软件架构入门及分类——微服务架构
  14. 水中贵族 || 百岁山的“骚路子”营销
  15. c#量化交易_全市场股票量化交易
  16. 期货市场十赌九输,钱都去哪里了?
  17. linux6.5安装中文字体,Linux(CentOS6.5)系统安装Windows字体
  18. 项目实训第四周第二次记录
  19. Neo4j 查询语法入门
  20. 老调重弹-ffmpeg解码视频图像

热门文章

  1. 收编娘内幕整合版(高质量PDF版)
  2. 基于51单片机的8个小彩灯花样流水灯proteus仿真汇编语言
  3. 怎么清理c盘只留下系统文件?
  4. 女生毕业论文致谢导师,导师批注亮了!网友:哈哈哈哈哈哈
  5. 课程linux实验报告,Linux课程综合训练实验报告
  6. 金数据统计表自动填写
  7. C语言学习day1、2
  8. labview事件结构的使用
  9. jieba提取关键词时筛选词性时单词性选择的一点注意事项
  10. Rebtel:打电话便宜到爆的VoIP服务