题目链接:Doors Breaking and Repairing

题目大意:有n个门,先手攻击力为x(摧毁),后手恢复力为y(恢复),输入每个门的初始“生命值”,当把门的生命值攻为0时,就无法恢复了。问:最多可以把几个门的生命值攻为0

思路:(1)当 x>y 的时候肯定所有的门的生命值都能降为0

   (2)当 x<=y 的时候,先手的最优策略就是每次去攻击那些当前“生命值”比自己攻击力小的门,使它们的生命值降为0;

     后手的最优策略就是去提高那些“生命值”比先手小的门的“生命值”,来减少先手“攻破”的门的数量,

     那些“生命值”本来就比先手攻击力高的先手就更攻破不了了;所以直接用门的“”生命值”小于等于x的门的个数除以2向上取整即可。

 /* */
# include <bits/stdc++.h>
using namespace std;
typedef long long ll; ll a[];
int main()
{
int n, x, y, num=, sum=;
cin>>n>>x>>y;
for(int i=; i<=n; i++ )
{
cin>>a[i];
if( a[i]<=x )
sum++;
}
if( x<=y )
cout<<ceil(sum/2.0)<<endl;
else
cout<<n<<endl;
return ;
}

Doors Breaking and Repairing的更多相关文章

  1. Doors Breaking and Repairing CodeForces - 1102C (思维)

    You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consi ...

  2. Codeforce 1102 C. Doors Breaking and Repairing

    Descirbe You are policeman and you are playing a game with Slavik. The game is turn-based and each t ...

  3. Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)

    题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门? 题解:首先如果\(x ...

  4. Codeforces Round #531 (Div. 3) ABCDEF题解

    Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...

  5. Reinvent the Wheel Often

    Reinvent the Wheel Often Jason P. Sage Just use something that exists-it's silly to reinvent the whe ...

  6. How can I protect derived classes from breaking when I change the internal parts of the base class?

    How can I protect derived classes from breaking when I change the internal parts of the base class? ...

  7. poj 1556 The Doors

    The Doors Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u   Java ...

  8. POJ 1556 The Doors(线段交+最短路)

    The Doors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5210   Accepted: 2124 Descrip ...

  9. poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)

    http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Su ...

随机推荐

  1. 在Centos7中创建.net core 项目,并用Apache做代理服务器部署.net core项目

    这一篇实例记录一次用Centos7创建并部署.net core项目的过程,希望能帮到用到的小伙伴. Kestrel 是 ASP.NET Core 项目模板中包括的默认 Web 服务器,Kestrel可 ...

  2. Python报错:ImportError: cannot import name 'ConnectionRefusedError'

    启动了一个flask server,结果报了标题中的错误. ImportError: cannot import name 'ConnectionRefusedError' 解决: pip insta ...

  3. Python进阶----反射(四个方法),函数vs方法(模块types 与 instance()方法校验 ),双下方法的研究

    Python进阶----反射(四个方法),函数vs方法(模块types 与 instance()方法校验 ),双下方法的研究 一丶反射 什么是反射: ​ 反射的概念是由Smith在1982年首次提出的 ...

  4. nodeJS从入门到进阶一(基础部分)

    一.Node.js基础知识 1.概念 简单的说 Node.js 就是运行在服务端的 JavaScript. Node.js 是JavaScript的运行环境 Node.js 使用了一个事件驱动.非阻塞 ...

  5. node连接Mysql报错ER_NOT_SUPPORTED_AUTH_MODE

    报错信息 本人系统安装的是mysql-installer-community-8.0.18.0.msi这个版本,然后我本地使用node-mysql去连接数据库. test.js文件 var mysql ...

  6. insmod/rmmod

    insmod -f 不检查目前kernel版本与模块编译时的kernel版本是否一致,强制将模块载入 -k 将模块设置为自动卸除 -m 输出模块的载入信息 -o <模块名称> 指定模块的名 ...

  7. restfulframework引用多对多外键

    记录一下工作中遇到的问题 最近在写restfulframework,感觉还是很便利的 首先贴一下文档地址 https://www.django-rest-framework.org/api-guide ...

  8. 【python】文件操作

    基本语法 open("文件名","访问方式") # 1. 打开文件 file = open("README.txt") # 2. 读取文件内 ...

  9. Linux系统 jboss/Tomcat服务器pdf文件乱码问题

    1.新搭建的环境,但是没有字符集,在windows上的电脑上复制了一份宋体, 字体C:\WINDOWS\FONTS\simsun.ttc(也就是宋体,大小为10M),把他重命名为 simsun.ttf ...

  10. Pthon面向对象-补充知识

    Pthon面向对象-补充知识 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.tracemalloc 标准库tracemalloc,可以统计内存使用情况,通过下面的案例可以看出内 ...