fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int I,T;
  7. int M1,M2,Con1,Con2,Cd1,Cd2,B1,B2,R1,R2;
  8. int Cstock0,Cstock1,Cstock2;
  9. int S0,S1,S2;
  10. bool isfeasible=true;
  11.  
  12. cin>>I>>T>>M1>>M2>>Con1>>Con2>>Cd1>>Cd2>>B1>>B2>>R1>>R2;
  13. cin>>Cstock0>>Cstock1>>Cstock2;
  14. cin>>S0>>S1>>S2;
  15.  
  16. int*d=new int[T];
  17. for(int i=0; i<T; i++)
  18. cin>>d[i];
  19.  
  20. int*p=new int[T];
  21. for(int i=0; i<T; i++)
  22. cin>>p[i];
  23.  
  24. int**x=new int*[I];
  25. for(int i=0; i<I; i++)
  26. {
  27. x[i]=new int[T];
  28. for(int t=0; t<T; t++)
  29. cin>>x[i][t];
  30. }
  31.  
  32. int*w=new int[T];
  33. for(int i=0; i<T; i++)
  34. cin>>w[i];
  35. int tempStock0=S0;
  36. int tempStock1=S1;
  37. int tempStock2=S2;
  38. int tempStockC0=0;
  39. int tempStockC1=0;
  40. int tempStockC2=0;
  41. int totalCd1=0;
  42. int totalCd2=0;
  43. int totalC0=0;
  44. int non1=0;
  45. int non2=0;
  46. int nonC;
  47.  
  48. for(int t=0; t<T; t++)
  49. {
  50. if(tempStock2+x[2][t]>=d[t]&&M2*B2>=x[2][t]&&M1*B1>=x[1][t]&&tempStock0+w[t]>=x[1][t])
  51. {
  52. if(x[2][t]%B2!=0)
  53. non2=non2+x[2][t]/B2+1;
  54. else
  55. non2=non2+x[2][t]/B2;
  56. if(x[1][t]%B2!=0)
  57. non1=non1+x[1][t]/B2+1;
  58. else
  59. non1=non1+x[1][t]/B2;
  60.  
  61. totalCd2=totalCd2+Cd2*x[2][t];
  62. totalCd1=totalCd2+Cd1*x[2][t];
  63. totalC0+=w[t]*p[t];
  64.  
  65. tempStock0=tempStock0+w[t]-x[1][t];
  66. tempStock1=tempStock1+x[1][t]-x[2][t];
  67. tempStock2=tempStock2+x[2][t]-d[t];
  68. tempStockC0=tempStockC0+tempStock0*Cstock0;
  69. tempStockC1=tempStockC1+tempStock1*Cstock1;
  70. tempStockC2=tempStockC2+tempStock2*Cstock2;
  71.  
  72.  
  73. nonC=non1*Con1+non2*Con2;
  74. }
  75.  
  76. else
  77. isfeasible=false;
  78. }
  79.  
  80. if(isfeasible==true)
  81. cout<<nonC<<","<<totalCd1+totalCd2<<","<<tempStockC0<<","<<tempStockC1<<","<<tempStockC2<<","<< totalC0;
  82.  
  83. else
  84. cout<<-1;
  85. }
  86.  
Runtime error #stdin #stdout 0s 4372KB
stdin
2 3
3 3
1000 1500
5 4
2000 1500
1 1
4 10 25
1000 1000 500
1200 1500 800
10 40 30
600 800 700
800 1400 800
200 1500 300
stdout
Standard output is empty