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 ...
随机推荐
- NET Core 3.0 AutoFac替换内置DI的新姿势
原文:NET Core 3.0 AutoFac替换内置DI的新姿势 .NET Core 3.0 和 以往版本不同,替换AutoFac服务的方式有了一定的变化,在尝试着升级项目的时候出现了一些问题. 原 ...
- 倾斜动画(SkewTransform)
Silverlight中的倾斜变化动画(SkewTransform)能够实现对象元素的水平.垂直方向的倾斜变化动画效果.我们现实生活中的倾斜变化效果是非常常见的,比如翻书的纸张效果,关门开门的时候门缝 ...
- easyUi——datetimebox绑定数据失效
在做easy-ui时候,绑定数据不管在怎么写,都绑定不上去,最后发现是因为 标签的ID没有写,尴尬了,记录一下,防止后期出错. ui代码 <script type="text/java ...
- Net实现钩子函数(Hook)以及通过SendMessage实现自动点击按钮和给文本框赋值
1.实现钩子函数 钩子(Hook)的实现需要三个主要的函数和一个委托 [DllImport("user32.dll", CharSet = CharSet.Auto, Callin ...
- 解决Ajax前台中文传到后台出现中文乱码
遇到的问题是: 前台利用Ajax, get方式向后台发送中文数据出现乱码. 解决办法是前台两次编码, 后台一次解码即可. 前台jsp文件 1 var text = "张三"; 3 ...
- 全网独发gensim中similarities.Similarity用法
index = similarities.MatrixSimilarity(lsi[corpus]) # 管网的原文翻译如下: 警告:similarities.MatrixSimilarity类仅仅适 ...
- flutter_screenutil
import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; ...
- 使用Mimikatz读取密码
法一: https://github.com/gentilkiwi/mimikatz/releases/tag/2.1.1-20170813 第一条:privilege::debug //提升权限 第 ...
- Android为TV端助力之查找当前界面焦点所在位置
View rootview = this.getWindow().getDecorView(); int focusId = rootview.findFocus().getId(); Log.i(T ...
- tomcat 安装记录 centos7 开放对外端口
//端口查询 [root@CentOS7 bin]# firewall-cmd --query-port=9090/tcp no //添加端口 [root@CentOS7 bin]# firewall ...