Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- const int nmax = 200000;
- int monsters[nmax+1];
- int v[nmax+1];
- int kill(int a, int b, int hp){
- int new_hp = hp % (a+b);
- int waits = -1;
- if(new_hp == 0){
- new_hp = b;
- waits = 0;
- }
- waits += new_hp / a;
- if(new_hp % a)
- waits++;
- return waits;
- }
- int main()
- {
- int n,a,b,k,i,hp,ans;
- scanf("%d %d %d %d",&n,&a,&b,&k);
- for(i=1; i<=n; i++){
- scanf("%d",&hp);
- monsters[i] = kill(a, b, hp);
- }
- sort(monsters+1, monsters+n+1);
- ans = 0;
- for(i=1; i<=n; i++)
- if(monsters[i] <= k){
- ans++;
- k -= monsters[i];
- }
- else
- break;
- printf("%d\n",ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment