fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main() {
  9. // your code goes here
  10. int n;
  11. cin>>n;
  12. int budget;
  13. cin>>budget;
  14.  
  15. vector<int> composition(n);
  16. vector<int> stock(n);
  17. vector<int> cost(n);
  18.  
  19.  
  20. for(int i=0;i<n;i++){
  21. cin>>composition[i];
  22. }
  23.  
  24. for(int i=0;i<n;i++){
  25. cin>>stock[i];
  26. }
  27.  
  28.  
  29. for(int i=0;i<n;i++){
  30. cin>>cost[i];
  31. }
  32.  
  33.  
  34.  
  35. bool val=false;
  36. int unit=1;
  37. int ans=0;
  38.  
  39.  
  40. while(val==false){
  41. int need=0;
  42. int totalcost=0;
  43.  
  44.  
  45. for(int i=0;i<n;i++){
  46. need = composition[i]*unit - stock[i];
  47. if(need<0){
  48. need=0;
  49. }
  50. totalcost=totalcost+need*cost[i];
  51.  
  52.  
  53. }
  54.  
  55. if(totalcost>budget){
  56. val=true;
  57.  
  58. }
  59. else{
  60. ans=unit;
  61. }
  62. unit++;
  63.  
  64. }
  65.  
  66. cout<<ans;
  67.  
  68.  
  69.  
  70.  
  71. return 0;
  72. }
Success #stdin #stdout 0.01s 5304KB
stdin
2 3 
1 2 
0 1
1 1
stdout
1