许可优化
许可优化
产品
产品
解决方案
解决方案
服务支持
服务支持
关于
关于
软件库
当前位置:服务支持 >  软件文章 >  Doors Breaking and Repairing(补题)解题报告

Doors Breaking and Repairing(补题)解题报告

阅读数 17
点赞 0
article_banner

题目描述:

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 nn doors, the ii-th door initially has durability equal to aiai.

During your move you can try to break one of the doors. If you choose door ii and its current durability is bibi then you reduce its durability to max(0,bi−x)max(0,bi−x) (the value xx is given).

During Slavik’s move he tries to repair one of the doors. If he chooses door ii and its current durability is bibi then he increases its durability to bi+ybi+y (the value yy is given). Slavik cannot repair doors with current durability equal to 00.

The game lasts 1010010100 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 00 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 nn, xx and yy (1≤n≤1001≤n≤100, 1≤x,y≤1051≤x,y≤105) — the number of doors, value xx and value yy, respectively.

The second line of the input contains nn integers a1 ,a2,…,ana1,a2,…,an (1≤ai≤1051≤ai≤105), where aiai is the initial durability of the ii-th door.

Output:

Print one integer — the number of doors with durability equal to 00 at the end of the game, if you and Slavik both play optimally.

Sample Input:

6 3 2
2 3 1 3 4 2

Sample Output:

6

Sample Input:

5 3 3
1 2 4 2 3

Sample Output:

2

Sample Input:

5 5 6
1 2 6 10 3

Sample Output:

2

题目大意:

一个游戏有2个人,A,B,按照回合制,面前有N扇们,每个回合分为2个阶段,A先走,他遇到门可以破坏他的耐久度,最大为x(题目会给),B后走,他遇到门可以修复到当前耐久度加y。问当游戏结束,有多少耐久度为0的门。

思路分析:


 1. 当x>y的时候,无论B如何修复,都会被A给破坏,所以游戏
 结束的时候,全部门都会破坏
 2. 当x<=y的时候,假设有5扇门,有3扇可以被A破坏,那么A破
 坏了其中一扇,到了B回合,他是不能破坏已经被A破坏成0的门,
 那么他可以去修复,3扇门其中一扇把他提高耐久度,让A破坏不
 了,那么这里找到规律,当x<=y的时候,所能破坏的门/2,当奇
 数的时候还要多加1,因为回合是A先,所以A肯定可以多破坏一个

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,x,y;
	while(cin >> n >> x >> y)
	{
		int num=0,a;
		for(int i=0;i<n;i++)
		{
			cin >> a; 
			if(x>=a)
			{
				num++;
			}
		}
		if(x>y)
		{
			cout << n << endl;
		}
		else if(x<=y)
		{
			if(num%2==0)
			{
				cout << num/2 << endl; 
			}
			else
			{
				cout << num/2+1 << endl;
			}
		}
	}
 } 



免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删


相关文章
QR Code
微信扫一扫,欢迎咨询~
customer

online

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 board-phone 155-2731-8020
close1
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

姓名不为空

姓名不为空
手机不正确

手机不正确

手机不正确
公司不为空

公司不为空

公司不为空