题目链接: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. SpringBoot中使用Interceptor

    https://www.cnblogs.com/chao555/p/9573102.html 1.创建自定义的拦截器并实现HandlerInterceptor接口 package com.demo.c ...

  2. java之spring mvc之文件上传

    目录结构如下: 注意,下面说的配置文件,一般都是值的src下的配置文件,即mvc.xml.如果是web.xml,则直接说 web.xml 1. 文件上传的注意点 表单必须是post提交,必须将 enc ...

  3. 遍历切片slice,结构体struct,映射map,interface{}的属性和值

    1 前言 说明:interface{}必须是前三者类型 2 代码 /** * @Author: FB * @Description: * @File: testOutput.go * @Version ...

  4. ThreadLocal简解

    ThreadLocal特点 ThreadLocal实现了线程间数据隔离,ThreadLocal的实例代表了一个线程局部的变量,每条线程都只能看到自己的值,并不会意识到其它的线程中也存在该变量.简单来说 ...

  5. npm全局模块卸载及默认安装目录修改方法

    卸载全局安装模块  npm uninstall -g <package> 卸载后,你可以到 /node_modules/ 目录下查看包是否还存在,或者使用以下命令查看:npm ls npm ...

  6. 【转载】C#中使用double.Parse方法将字符串转换为双精度double类型

    在C#编程过程中,很多时候涉及到数据类型的转换,例如将字符串类型的变量转换为双精度浮点类型double就是一个常见的类型转换操作,double.Parse方法是C#中专门用来将字符串转换为double ...

  7. Unity Physicals Rigidbody with multiple colliders

    Rigidbody with multiple colliders adding colliders changes the center of mass and rotation behaviour ...

  8. glfw之hello world

    mac上用cocoa做imshow,资料似乎不好找,即便找到也需要和OC混编,而不是纯C.这不够纯粹.考虑用opengl做通用的.跨平台的imshow.先入门一下opengl,从glfw官方例子入手. ...

  9. 产生大于N的Smith数

    实验三  求Smith数 实验目的: 通过本次实验,掌握穷举算法的基本思想. 实验环境: 硬件:PC机 软件:windows操作系统,C语言 实验内容: 若一个合数的质因数分解式逐位相加之和等于其本身 ...

  10. Activity知识点详解

    Activity知识点详解 一.什么是Activity 官方解释: The Activity class is a crucial component of an Android app, and t ...