Doors Breaking and Repairing
题目链接: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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #531 (Div. 3) C. Doors Breaking and Repairing (博弈)
题意:有\(n\)扇门,你每次可以攻击某个门,使其hp减少\(x\)(\(\le 0\)后就不可修复了),之后警察会修复某个门,使其hp增加\(y\),问你最多可以破坏多少扇门? 题解:首先如果\(x ...
- Codeforces Round #531 (Div. 3) ABCDEF题解
Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...
- Reinvent the Wheel Often
Reinvent the Wheel Often Jason P. Sage Just use something that exists-it's silly to reinvent the whe ...
- 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? ...
- poj 1556 The Doors
The Doors Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u Java ...
- POJ 1556 The Doors(线段交+最短路)
The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5210 Accepted: 2124 Descrip ...
- poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)
http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS Memory Limit: 131072K Total Su ...
随机推荐
- netcore访问本地磁盘
public void ConfigureServices(IServiceCollection services) { services.AddDirectoryBrowser(); }public ...
- 浮动IP地址(Float IP)与 ARP欺骗技术
浮动IP地址: 一个网卡是可以添加多个IP的. 就是多个主机工作在 同一个集群中,即两台主机以上.每台机器除了自己的实IP外,会设置一个浮动IP,浮动IP与主机的服务(HTTP服务/邮箱服务)绑在一起 ...
- Python报错:ImportError: cannot import name 'ConnectionRefusedError'
启动了一个flask server,结果报了标题中的错误. ImportError: cannot import name 'ConnectionRefusedError' 解决: pip insta ...
- Java之路---Day09(继承)
2019-10-23-22:58:23 目录 1.继承 2.区分成员变量重名的方法 3.区分成员方法重名的方法 4.继承中重写与重载的区别 5.继承中覆盖重写的注意事项 6.继承中覆盖重写的设计原则 ...
- 自学Python编程的第三天----------来自苦逼的转行人
2019-09-14 11:09:50 学Python的第三天和写博客的第三天 本来第三天的内容前天就应该发的,但是因为有点难度,用了两天的时间去学习,按道也是昨天发, 因为中秋导致今天早上发,第三天 ...
- 采用__call__ 实现装饰器模式
装饰器模式在实现中也是很常见的:比如手机贴膜,手机壳 都是为了给手机增加一些额外功能 增加耐操 装饰器模式的本质就是对对象二次包装,赋额外功能 __call__ __call__是python魔术方法 ...
- mvc和mvvm模式
一. Mvvm定义 MVVM是Model-View-ViewModel的简写.即模型-视图-视图模型.[模型]指的是后端传递的数据.[视图]指的是所看到的页面.[视图模型]mvvm模式的核心,它是连接 ...
- LCD 驱动 S3C2440A
LCD Control 1 Register 以16BPP为例 LCD Control 2 Register LCD Control 3 Register LCD Control 4 Register ...
- python私有工具库小结
1.一些试用py工具清单 https://www.zhihu.com/question/60402355/answer/752917744?utm_source=wechat_session& ...
- 关于何时执行shiro AuthorizingRealm 里的 doGetAuthenticationInfo与doGetAuthorizationInfo
1.doGetAuthenticationInfo执行时机如下 当调用Subject currentUser = SecurityUtils.getSubject(); currentUser.log ...