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

 
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
读入的时候进行预处理,先模一下a+b,如果变成0了的话+b,不为零的话-a。本质上都是看在不跳过的情况下,最后一轮里自己攻击后处于什么状况。然后对数组由小到大排序。这里有一个贪心的思想,因为在此之后都是要靠k次跳过对手的攻击,所以说怪物剩余血量越少对自己越有利,这样能尽可能用较少的跳过次数把怪KO。之后遍历数组统计分数,同时相应的减去跳过次数。
#include <bits/stdc++.h>
using namespace std;
int n,a,b,k;
int h[];
long long ans=;
int main()
{
cin>>n>>a>>b>>k;
int i;
for(i=;i<=n;i++)
{
scanf("%d",&h[i]);
h[i]%=(a+b);
if(h[i]==)h[i]+=b;
else h[i]-=a;
}
sort(h+,h+n+);
for(i=;i<=n;i++)
{
if(h[i]<=)
{
ans++;//血量小于0说明最后一轮自己能直接获得人头
continue;
}
else
{
if(h[i]-k*a<=)
{
ans++;
if(h[i]%a==)k-=h[i]/a;
else k-=(h[i]/a+);
}
else
{
continue;
}
}
}
cout<<ans<<endl; return ;
}

 

Codeforces #617 (Div. 3) D. Fight with Monsters(贪心,排序)的更多相关文章

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

    D : Fight with Monsters 题目大意 : 有一组数,每个值对应着一个怪物的 hp 值,现在有两个人,一个自己一个对手,每个人有一个攻击值, 两个人轮流攻击怪物,如果是自己将怪物先打 ...

  2. Codeforces - 102222H - Fight Against Monsters - 贪心

    https://codeforc.es/gym/102222/problem/H 题意:有一堆怪兽,怪兽有HP和ATK.你有一个英雄,英雄每次先被所有怪兽打,然后打其中一个怪兽.打的伤害递增,第一次1 ...

  3. Codeforces #617 (Div. 3) C. Yet Another Walking Robot

    There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0) . It ...

  4. Codeforces #617 (Div. 3)B. Food Buying

    Mishka wants to buy some food in the nearby shop. Initially, he has ss burles on his card. Mishka ca ...

  5. Codeforces 631 (Div. 2) E. Drazil Likes Heap 贪心

    https://codeforces.com/contest/1330/problem/E 有一个高度为h的大顶堆:有2h -1个不同的正整数,下标从1到2h−1,1<i<2h, a[i] ...

  6. Codeforces #366 (Div. 2) D. Ant Man (贪心)

    https://blog.csdn.net/liangzhaoyang1/article/details/52215276  原博客 原来好像是个dp题,不过我看了别人的博客使用贪心做的 复杂度(n^ ...

  7. Codeforces Round #617 (Div. 3) 补题记录

    1296A - Array with Odd Sum 题意:可以改变数组中的一个数的值成另外一个数组中的数,问能不能使数组的和是个奇数 思路:签到,如果本来数组的和就是个奇数,那就OK 如果不是,就需 ...

  8. Codeforces Round #617 (Div. 3) 题解

    又是隔了一年才来补题的我 A.B水题就不用说了 C - Yet Another Walking Robot C题我居然卡了一会,最后决定用map水,结果出来看了看题解,居然真的是map...没想到会出 ...

  9. [CF百场计划]Codeforces Round #617 (Div. 3)

    A. Array with Odd Sum Description You are given an array \(a\) consisting of \(n\) integers. In one ...

随机推荐

  1. Day2 异常 日志 反射

    调用方如何获知调用失败的信息? 1.约定返回错误码.处理一个文件,如果返回0,表示成功,返回其他整数,表示约定的错误码: 2.在语言层面上提供一个异常处理机制 异常 异常是一种class,因此它本身带 ...

  2. matlab 绘制原始信号的谐波

    这里以锯齿信号为例: clear;clc; figure time = 0:1/20:1000; wave = sawtooth(time); subplot(3, 1, 1); plot(time, ...

  3. Centos6.10-FastDFS-Tracker.conf示例配置

    Centos610系列配置 FastDFS_Tracker.conf示例配置 # is this config file disabled # false for enabled # true for ...

  4. 「JSOI2015」最小表示

    「JSOI2015」最小表示 传送门 很显然的一个结论:一条边 \(u \to v\) 能够被删去,当且仅当至少存在一条其它的路径从 \(u\) 通向 \(v\) . 所以我们就建出正反两张图,对每个 ...

  5. Java编写POST请求

    package com.mytesting; import java.io.DataOutputStream; import java.io.InputStream; import java.net. ...

  6. PyCharm安装及汉化设置为中文(附汉化包)

    下载:https://www.jetbrains.com/pycharm/download/#section=windows 下载社区版免费 双击运行安装程序 Next 选择安装路径安装 创建桌面快捷 ...

  7. 安装nodejs时提示Leaving directory

    在按照标准的编译命令./configure =>make =>make install 在make的时候发生错误: ../deps/v8/src/base/platform/mutex.h ...

  8. 我的18vps~

    自从买了18vps的香港虚拟主机后,就面临一个问题,浏览器无法访问它的apache服务,后来发现,需要同时开启nginx服务: /usr/local/nginx/sbin/nginx -c /usr/ ...

  9. js的split() 方法和join()方法

    定义和用法 split() 方法用于把一个字符串分割成字符串数组. String.split() 执行的操作与 Array.join 执行的操作是相反的. join() 方法用于把数组中的所有元素放入 ...

  10. 【原】docker-compose 管理docker的多容器配置

    docker-compose管理docker的多容器配置,实现docker的自动化. version: '3.4' x-defaults: &defaults restart: unless- ...