fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int sum(int a[], int b, int c);
  6.  
  7. int main()
  8. {
  9. int i = 0;
  10. int all = 0;
  11. float numBoxes;
  12. unsigned int quantityCookiesInBox;
  13. unsigned short quantityMonsters;
  14. unsigned int fastEating;
  15. unsigned int HowManyTest;
  16.  
  17.  
  18. cin >> HowManyTest;
  19.  
  20. for (int i = 0; i < HowManyTest; i++)
  21. {
  22. cin >> quantityMonsters >> quantityCookiesInBox;
  23.  
  24. if ((1 <= quantityMonsters) && (quantityCookiesInBox <= 10000) && (1 <= quantityCookiesInBox) && (quantityCookiesInBox <= 1000000000))
  25. {
  26. int* monsters;
  27. monsters = new int[quantityMonsters];
  28.  
  29. for (int d = 0; d < quantityMonsters; d++)
  30. {
  31. cin >> fastEating;
  32. if ((0<fastEating) && (fastEating <= 100000))
  33. {
  34. monsters[d] = fastEating;
  35. }
  36. else
  37. exit(0);
  38. }
  39.  
  40. for (int d = 0; d < quantityMonsters; d++)
  41. {
  42. all = sum(monsters, quantityMonsters, d);
  43. }
  44.  
  45. numBoxes = (float)all / (float)quantityCookiesInBox;
  46.  
  47. if (numBoxes == (int)numBoxes)
  48. {
  49. cout << (int)numBoxes << endl;
  50. }
  51. else
  52. {
  53. cout << (int)numBoxes + 1 << endl;
  54. }
  55. delete[] monsters;
  56. }
  57.  
  58. else
  59. break;
  60. }
  61.  
  62. return 0;
  63. }
  64.  
  65. int sum(int a[], int b, int c)
  66. {
  67. int allDay = 86400;
  68. int allHowMuch = 0;
  69.  
  70. for (int c = 0; c < b; c++)
  71. {
  72. allHowMuch += (allDay / a[c]);
  73. }
  74. return allHowMuch;
  75. }
Success #stdin #stdout 0s 15240KB
stdin
2
2 10
3600
1800
3 356
123
32999
10101
stdout
8
2