Guest User

Untitled

a guest
Feb 4th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1.     #include <iostream>
  2.     #include <cstdio>
  3.     #include <algorithm>
  4.     using namespace std;
  5.      
  6.     const int nmax = 200000;
  7.      
  8.     int monsters[nmax+1];
  9.     int v[nmax+1];
  10.      
  11.     int kill(int a, int b, int hp){
  12.         int new_hp = hp % (a+b);
  13.         int waits = -1;
  14.         if(new_hp == 0){
  15.             new_hp = b;
  16.             waits = 0;
  17.         }
  18.         waits += new_hp / a;
  19.         if(new_hp % a)
  20.             waits++;
  21.         return waits;
  22.     }
  23.      
  24.     int main()
  25.     {
  26.         int n,a,b,k,i,hp,ans;
  27.         scanf("%d %d %d %d",&n,&a,&b,&k);
  28.         for(i=1; i<=n; i++){
  29.             scanf("%d",&hp);
  30.             monsters[i] = kill(a, b, hp);
  31.         }
  32.         sort(monsters+1, monsters+n+1);
  33.         ans = 0;
  34.         for(i=1; i<=n; i++)
  35.             if(monsters[i] <= k){
  36.                 ans++;
  37.                 k -= monsters[i];
  38.             }
  39.             else
  40.                 break;
  41.         printf("%d\n",ans);
  42.         return 0;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment