fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. # define C continue;
  5. # define R return
  6.  
  7. # define D double
  8. # define I insert
  9. # define ll long long
  10. # define ld long double
  11.  
  12. # define ull unsigned long long
  13. # define ui unsigned int
  14.  
  15. # define pb push_back
  16. # define pf push_front
  17.  
  18. # define vi vector < int >
  19. # define vc vector < char >
  20. # define vs vector < string >
  21. # define vb vector < bool >
  22. # define vd vector < D >
  23. # define vll vector < ll >
  24. # define vull vector < ull >
  25. # define vld vector < ld >
  26. # define PQ priority_queue
  27.  
  28. # define vvi vector < vector < int > >
  29. # define vvb vector < vector < bool > >
  30. # define vvc vector < vector < char > >
  31. # define vvll vector < vector < ll > >
  32. # define vvd vector < vector < D > >
  33. # define vvld vector < vector < ld > >
  34.  
  35. # define all(v) (v).begin() , (v).end()
  36. # define allrev(v) (v).rbegin() , (v).rend()
  37. # define allcomp(v) v.begin() , v.end() , comp
  38. # define allrevcomp(v) v.rbegin() , v.rend() , comp
  39.  
  40. # define pii pair < int , int >
  41. # define pll pair < ll , ll >
  42. # define pld pair < ld , ld >
  43. # define pDD pair < D , D >
  44.  
  45. # define vpld vector < pld >
  46. # define vpii vector < pii >
  47. # define vpll vector < pll >
  48. # define vpDD vector < pDD >
  49.  
  50. # define vvpii vector < vector < pii > >
  51. # define F first
  52. # define S second
  53. # define mp make_pair
  54.  
  55. # define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
  56.  
  57. # define pp(n) printf("%.10Lf",n);
  58. # define line cout<<"\n";
  59. # define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
  60.  
  61. string vow = "aeiou";
  62. int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  63.  
  64. const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
  65. const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
  66.  
  67. const int dx[] = { -1 , 0 , 0 , 1 } ;
  68. const int dy[] = { 0 , -1 , 1 , 0 } ;
  69.  
  70. const ld pie = 3.1415926535897932384626 ;
  71. const ll mod = 1e9 + 7 ;
  72.  
  73. /// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
  74.  
  75. void solve ( int test_case )
  76. {
  77. int n , a , b , k ;
  78. cin >> n >> a >> b >> k ;
  79.  
  80. vi v ( n ) ;
  81. for ( int i=0 ; i < n ; i ++ )
  82. {
  83. int temp ;
  84. cin >> temp ;
  85.  
  86. int t = temp / ( a + b ) ;
  87. t -- ;
  88.  
  89. if ( t < 0 ) t = 0 ;
  90.  
  91. temp = temp - (a+b) * t ;
  92. v[i] = temp ;
  93. }
  94.  
  95. for ( int i=0 ; i < n ; i ++ )
  96. {
  97. int &temp = v[i] ;
  98. int mv = 1 ;
  99.  
  100. for ( ; ; mv ^= 1 )
  101. {
  102. if ( mv == 1 )
  103. {
  104. temp -= a ;
  105. if ( temp <= 0 )
  106. {
  107. v[i] = -1 ;
  108. break ;
  109. }
  110. }
  111.  
  112. else
  113. {
  114. if ( temp - b > 0 )
  115. {
  116. temp -= b ;
  117. C ;
  118. }
  119.  
  120. else break ;
  121. }
  122. }
  123. }
  124.  
  125. sort ( all ( v ) ) ;
  126.  
  127. int i=0 ;
  128. while ( i < n && v[i] == -1 ) i ++ ;
  129.  
  130. for ( ; i < n ; i ++ )
  131. {
  132. int val = v[i] ;
  133.  
  134. int mv = 1 + (val - 1) / a ;
  135. if ( mv > k )
  136. break ;
  137.  
  138. k -= mv ;
  139. v[i] = -1 ;
  140. }
  141.  
  142. int ans = 0 ;
  143.  
  144. for ( auto i : v )
  145. {
  146. if ( i <= 0 )
  147. ans ++ ;
  148. }
  149.  
  150. cout << ans ; line ;
  151.  
  152.  
  153. }
  154.  
  155. int main()
  156. {fast
  157. int t = 1;
  158. // cin >> t;
  159.  
  160. for ( int i=0 ; i < t ; i++ ) solve(i);
  161. return 0;
  162. }
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
11125