fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N=1e5*5+10;
  4. long long n,a,w[N],b;
  5. bool check(){
  6. bool flag=true;
  7. for(int i=1;i<=n;i++){
  8. if(w[i]>0){
  9. flag=false;
  10. break;
  11. }
  12. }
  13. return flag;
  14.  
  15. }
  16. int main(){
  17. ios::sync_with_stdio(false);
  18. cin.tie(0),cout.tie(0);
  19. cin>>n>>a>>b;
  20. for(int i=1;i<=n;i++){
  21. cin>>w[i];
  22. }
  23. long long s=0;
  24. while(1){
  25. if(check()){
  26. cout<<s;
  27. return 0;
  28. }
  29. long long maxx=-N,maxi=0;
  30. for(int i=1;i<=n;i++){
  31. w[i]-=a;
  32. if(w[i]>=maxx){
  33. maxx=w[i];
  34. maxi=i;
  35. }
  36. }
  37. w[maxi]-=b;
  38. s++;
  39. }
  40. }
Success #stdin #stdout 0.01s 5220KB
stdin
3 2 1
1
2
3
stdout
1