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 turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.
There are n doors, the i-th door initially has durability equal to ai.
During your move you can try to break one of the doors. If you choose door i and its current durability is bi then you reduce its durability to max(0,bi−x) (the value x is given).
During Slavik’s move he tries to repair one of the doors. If he chooses door i and its current durability is bi then he increases its durability to bi+y (the value y is given). Slavik cannot repair doors with current durability equal to 0.
The game lasts 10100 turns. If some player cannot make his move then he has to skip it.
Your goal is to maximize the number of doors with durability equal to 0 at the end of the game. You can assume that Slavik wants to minimize the number of such doors. What is the number of such doors in the end if you both play optimally?
Input
The first line of the input contains three integers n, x and y (1≤n≤100, 1≤x,y≤105) — the number of doors, value x and value y, respectively.
The second line of the input contains n integers a1,a2,…,an (1≤ai≤105), where ai is the initial durability of the i-th door.
Output
Print one integer — the number of doors with durability equal to 0 at the end of the game, if you and Slavik both play optimally.
Examples
inputCopy 6 3 2 2 3 1 3 4 2 outputCopy 6 inputCopy 5 3 3 1 2 4 2 3 outputCopy 2 inputCopy 5 5 6 1 2 6 10 3 outputCopy 2 Note
Clarifications about the optimal strategy will be ignored.
题意大概是两个人玩游戏一个警察,一个坏蛋,一个人破门,一个人补门,警察像破开尽可能多的门,坏蛋想让警察破开门尽可能少,这时候就疑惑了,这到底是让我们求最大值,还是最小值?在这里我们看到,两个人的意愿也改变不了必然的结果,就拿这一组数据 6 3 2 2 3 1 3 4 2 6扇门,警察破门掉 3个耐久,坏蛋修门增加2个耐久,警察与坏蛋轮流操作,警察为破开更多的们,会选择第一次就能破开,或者说最小耐久值的门,坏蛋也是这样想的,他会修补那些一次就被警察破门的门,前提是坏蛋增加耐久大于警察破门,不然以题目这样的数据,一直撞迟早也是撞开的,当坏蛋修补增加的耐久大于警察撞门耐久时,便有了以下操作 5 5 6 1 2 6 10 3 警察第一次撞门 1 坏蛋第一次修门 2 警察第二次撞门 3 再往后警察一次撞不开一扇门,而坏蛋使门的耐久度越来越高,这就得出了必然的结果。 下面是AC code
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int x,y,n,a[10000],s;
while(cin>>n>>x>>y)
{
s=0;
for(int i=1;i<=n;i++)
cin>>a[i];
if(x>y)
{
cout<<n<<endl;
}
else if(x<=y)
{
sort(a+1,a+1+n);
int w=1;
for(int i=1;i<=n;i++)
{
if(a[i]<=x)
s++;
}
if(s%2==1) s=s/2+1;
else s=s/2;
cout<<s<<endl;
}
}
}
- 软件更新时候出现和原包名冲突
- 一个数字截取引发的精度问题(三)
- HTML生成PDF(c#)
- 一个数字截取引发的精度问题(二)
- 【独家推送】GoogLeNet构建技术分析因子的模式识别基于TensorFlow
- 一个数字截取引发的精度问题(一)
- 基于TLS1.3的微信安全通信协议mmtls介绍
- 在 WCF 中使用高效的 BinaryFormatter 序列化
- Visual Studio 2012 中的ASP.NET Web API
- gradeview可拖动效果实现
- 【Python量化投资】拟合具有非平稳特征的神经网络对股票进行预测
- 使同事羡慕不已的8个npm命令
- JavaScript代码风格要素
- 从 WebAPI Beta 更新到WebAPI RC
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Yii2 queue的队列使用详解
- ThinkPHP5+jQuery+MySql实现投票功能
- Smarty模板配置实例简析
- php利用ZipArchive类操作文件的实例
- Yii框架页面渲染操作实例详解
- PHP数据源架构模式之表入口模式实例分析
- PHP pthread拓展使用和注意点
- centos6.5下安装zabbix2.4的教程图解
- php经典趣味算法实例代码
- centos7 设置grub密码及单用户登录实例代码
- php面向对象基础详解【星际争霸游戏案例】
- Linux系统下Nginx支持ipv6配置的办法
- Smarty模板变量与调节器实例详解
- Linux中搭建完整的samba服务器全攻略(centos版)
- Thinkphp5 自定义上传文件名的实现方法