1. 程式人生 > >Doors Breaking and Repairing CodeForces - 1102C (思維)

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 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 

ai">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,bix)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 

i">ii and its current durability is bibi then he increases its durability to bi+ybi+y (the value yyis 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 (1n1001≤n≤100, 1x,y1051≤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 (1ai1051≤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
6 3 2
2 3 1 3 4 2
Output
6
Input
5 3 3
1 2 4 2 3
Output
2
Input
5 5 6
1 2 6 10 3
Output
2

Note

Clarifications about the optimal strategy will be ignored.

 

題目連結:https://vjudge.net/problem/CodeForces-1102C

題意:給你一個含有N個數的陣列,每一個元素代表一個門的當前防禦值

每一次你可以對門攻擊x個點數,而一個神仙可以對門進行y個點數的防禦值提升。

當一次你對門的攻擊使這個門的防禦值小於等於0的時候,這個門就壞掉了,神仙也沒法修復了。

問:當你和神仙都採取最優的策略的時候,你最多可以砸壞幾個門?

思路:

分2種情況

1: X>Y ,這樣的話,每一個門你都可以給砸壞。(不用解釋吧)

2:當x<=y,這樣你的最優策略就是每一次去砸那些當前防禦值比你的攻擊力x值小的門,一次就可以給砸壞,

而神仙的最優策略使去提升那些當前防禦值比你的攻擊力x值小的門,一次來減少你的數量。

通過樣例我們可以推出公式,如果初始化的時候有cnt個門當前防禦值比你的攻擊力x值小,那麼答案就是(ans+1)/2

 

我的AC程式碼:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n,x,y;
int a[maxn];
int main()
{
    gbtb;
    cin>>n>>x>>y;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    if(x<=y)
    {
        int ans=0;
        repd(i,1,n)
        {
            if(a[i]<=x)
            {
                ans++;
            }
        }
        ans=(ans+1)/2;
        cout<<ans<<endl;
    }else
    {
        cout<<n<<endl;
    }
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

MY BLOG:
https://www.cnblogs.com/qieqiemin/