怪物补刀(贪心)

Fight with Monsters

There are n monsters standing in a row numbered from 1 to n. The i-th monster has hi health points (hp). You have your attack power equal to a hp and your opponent has his attack power equal to b hp.
n只怪兽站成一排,从1到n。第i只怪兽有hi的血量,你的攻击力为a,对手的攻击力为b。

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 0.
你和你的竞争者需要对抗这些怪兽,从第一只怪兽开始,只有击败后才能移动到第二只,依次往后。怪兽的hp为0时死亡。

The fight with a monster happens in turns.
轮流攻击怪兽。

You hit the monster by a hp. If it is dead after your hit, you gain one point and you both proceed to the next monster.
只有你攻击后怪物死亡,才能给你增加一分。

Your opponent hits the monster by b 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 k times in total (for example, if there are two monsters and k=4, then you can use the technique 2 times on the first monster and 1 time on the second monster, but not 2 times on the first monster and 3 times on the second monster).
你有一种能力,能够让你的对手跳过一回合。你最多能够使用k次。

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,b and k (1≤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 n integers h1,h2,…,hn (1≤hi≤109), where hi is the health points of the i-th monster.

Output

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

Examples

input
6 2 3 3
7 10 50 12 1 8

output
5

input
1 1 100 99
100

output
1

input
7 4 2 1
1 3 5 4 2 7 6

output
6

解题思路:

1.本题目的目的是分数,直接相关的就是自己打死的怪物的数量。自己的技能应该用在 自己容易打死的。关键是寻找什么是容易打死的。
2.在某个回合结束后,自己再用一招毙命的,这是最容易打死的。其次就是用更少的技能自己打死的。
3.为了使分数更高,应把怪物按 容易度排个名次,把技能用在容易打死的怪物身上。

源码:

#include<bits/stdc++.h>
using namespace std;
int score()
{
    vector<int> v;
    int n,a,b,k,h,d,c,ans=0;
    cin>>n>>a>>b>>k;
    int s=a+b;
    while(n--)
    {
        cin>>h;
        d=(h-1)%s+1;
        if(d<=a)
            ans++;
        else
            v.push_back(d);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        c=(v[i]-1)/a;
        if(c<=k)
        {
            k=k-c;
            ans++;
        }
        else
            return ans;
    }
}
int main()
{
    cout<<score()<<endl;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

莫余

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值