CodeForces 1102C-简单的思维题

题目链接:http://codeforces.com/problemset/problem/1102/C

C. Doors Breaking and Repairing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples

input

Copy

6 3 2
2 3 1 3 4 2

output

Copy

6

input

Copy

5 3 3
1 2 4 2 3

output

Copy

2

input

Copy

5 5 6
1 2 6 10 3

output

Copy

2

Note

Clarifications about the optimal strategy will be ignored.

题目大意:这道题的题意认真读的话很简单,就是两个人做游戏。在两个人面前有n张门,每一个门的耐久度(durability)都已给出。两个人一个人破坏门(每次减少门的耐久度x)

另一个人是修门(每次增加门的耐久度y)两个人是回合制的,如果一个门的耐久度降到了0,则这个门将无法被修。

题目思维:题目中已给出回合数10的100次方,因此不可能都经历一边。这时候我们就要讨论x和y的关系,假设当x大于y的时候,每个回合要不门的耐久度下降,要不一个门被破坏

(因为x-y>0)这个时候所有的门都能够被破坏。(回合数足够多)

如果x<=y,我们只能去破坏一次可以破坏的门,假设我们没有去破坏一次可以破坏的(即你的回合后这个门的耐久度不是0)另一个人就要来修,这个门的耐久度要不上升,要不就不变

因此我们只能去破坏可以一次破坏的门,而当你破坏一个可以破坏的门后,另一个人会去修你原本可以一次破坏的门,这时你可以破坏的门数量就要下降。因此你破坏的门只能对半分。

附上AC代码:

#include<stdio.h>
int main()
{
   int n,x,y,a[110],ans;
   scanf("%d%d%d",&n,&x,&y);
      ans=0;
        for(int i=1;i<=n;i++)
       {
             scanf("%d",&a[i]);
             if(a[i]<=x) ans++;//统计耐久度小于你的破坏值的门
       }
       if(x>y) printf("%d\n",n);//第一种情况
       if(x<=y)
       {
           if(ans%2==0) printf("%d\n",ans/2);//当可以门数是偶数
           else printf("%d\n",ans/2+1);//可以破坏的是奇数,你是先手,肯定你的加一
       }
       return 0;
} 

(第一次博客,多多见谅)

原文地址:https://www.cnblogs.com/tombraider-shadow/p/10294434.html

时间: 2024-08-07 22:58:19

CodeForces 1102C-简单的思维题的相关文章

Codeforces A. Sweet Problem(思维题)

传送门 题意: 有红,绿,蓝三种颜色的糖各r,g,b个,每天要吃两个糖且颜色不同,问最多能吃多少天 思路: 先把r,g,b排序,从小到大为a,b,c如果a+b<=c,结果肯定输出a+b 否则输出(a+b+c)/2 原因:为了使天数最多,每次取最多和次多的两堆,当次多的变成和最少的相等时,把最多的那个平分个最少和中间那一堆,(如果最多的为奇数,那么总共还剩一个,如果为偶数,所有糖果用完),所以说最优解剩下的糖果不超过两个(a+b>c时) 代码 #include <iostream>

Codeforces Round #259 (Div. 2) (简单模拟实现题)

题目链接:http://codeforces.com/problemset/problem/454/A A. Little Pony and Crystal Mine time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Twilight Sparkle once got a crystal from the Crystal Mine

贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

题目传送门 1 /* 2 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 3 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0),先从1开始找到已经套好的娃娃层数, 4 其他是2次操作,还要减去k-1个娃娃是只要套上就可以 5 详细解释:http://blog.csdn.net/firstlucker/article/details/46671251 6 */ 7 #include <cstdio> 8 #i

codeforces 848B Rooter&#39;s Song 思维题

http://codeforces.com/problemset/problem/848/B 给定一个二维坐标系,点从横轴或纵轴垂直于发射的坐标轴射入(0,0)-(w,h)的矩形空间.给出点发射的坐标轴,位置,延迟时间,发生碰撞则交换方向.求最后每个点的射出位置. 首先我们观察能得出两个结论,1. 类似蚂蚁爬树枝的问题,相遇只会交换方向,所以最后的射出点集只会因为碰撞而改变动点与射出点的对应关系,而不会增加减少射出点集.2.我们根据其射入位置和延迟时间可以计算出一个值v=pos-time,只有这

CodeForces 1131B(思维题)

You still have partial information about the score during the historic football match. You are given a set of pairs (ai,bi)(ai,bi), indicating that at some point during the match the score was "aiai: bibi". It is known that if the current score

Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) A. Contest for Robots(思维题)

Polycarp is preparing the first programming contest for robots. There are nn problems in it, and a lot of robots are going to participate in it. Each robot solving the problem ii gets pipi points, and the score of each robot in the competition is cal

ACM: Gym 101047K Training with Phuket&#39;s larvae - 思维题

Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Practice Description standard input/output Thai cuisine is known for combining seasonings so that every dish has flavors that are s

实现strcmp很简单的思维

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> void strcom(char *str1 , char *str2,int *num) { int a = 0; int count = 0; //关键在这里 用指针进行循环判断 while (*str1&&*str2) { str1++; str2++; if ((a=*str1 - *str2) != 0) { *num

Unique Encryption Keys (思维题 预处理)

题目 题意:给m个数字, q次询问, 询问b到e之间如果有重复数字就输出, 没有就输出OK 思路:用f[i]数组 记录从i开始向后最近的有重复数字的 位置, 如 1 3 2 2, 则f[1] = 4; 如果离a最近的重复数字的位置 都大于b, 就说明没有重复数字. f[]数组需要预处理,从后向前. 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <vector>