Codeforces Round #617 (Div. 3)D. Fight with Monsters贪心

D. Fight with Monsters

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are nn monsters standing in a row numbered from 11 to nn. The ii-th monster has hihi health points (hp). You have your attack power equal to aa hp and your opponent has his attack power equal to bb hp.

You and your opponent are fighting these monsters. Firstly, you and your opponent go to the first monster and fight it till his death, then you and your opponent go the second monster and fight it till his death, and so on. A monster is considered dead if its hp is less than or equal to 00.

The fight with a monster happens in turns.

  1. You hit the monster by aa hp. If it is dead after your hit, you gain one point and you both proceed to the next monster.
  2. Your opponent hits the monster by bb hp. If it is dead after his hit, nobody gains a point and you both proceed to the next monster.

You have some secret technique to force your opponent to skip his turn. You can use this technique at most kk times in total (for example, if there are two monsters and k=4k=4, then you can use the technique 22 times on the first monster and 11 time on the second monster, but not 22 times on the first monster and 33 times on the second monster).

Your task is to determine the maximum number of points you can gain if you use the secret technique optimally.

Input

The first line of the input contains four integers n,a,bn,a,b and kk (1≤n≤2⋅105,1≤a,b,k≤1091≤n≤2⋅105,1≤a,b,k≤109) — the number of monsters, your attack power, the opponent's attack power and the number of times you can use the secret technique.

The second line of the input contains nn integers h1,h2,…,hnh1,h2,…,hn (1≤hi≤1091≤hi≤109), where hihi is the health points of the ii-th monster.

Output

Print one integer — the maximum number of points you can gain if you use the secret technique optimally.

Examples

input

Copy

6 2 3 3
7 10 50 12 1 8

output

Copy

5

input

Copy

1 1 100 99
100

output

Copy

1

input

Copy

7 4 2 1
1 3 5 4 2 7 6

output

Copy

6

题意就不说了

先把血量对a+b取余然后就是怪物死的回合

然后算出杀死每个怪物浪费的次数

然后排序贪心

#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
int main()
{
    long long n,a,b,k;
    scanf("%I64d%I64d%I64d%I64d",&n,&a,&b,&k);
    long long sum=a+b;
    for(int i=1; i<=n; i++)
    {
        long long tmp;
        long long res;
        scanf("%I64d",&tmp);
        res=tmp%sum;
        if(res==0) res+=sum;
        long long num=res/a;
        if(res%a==0) num--;
        arr[i]=num;
    }
    sort(arr+1,arr+1+n);
    long long ans=0;
    for(int i=1; i<=n; i++)
    {
        //cout<<arr[i]<<endl;
        if(k>=arr[i])
        {
            ans++;
            k-=arr[i];
        }
    }
    printf("%I64d\n",ans);
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值