fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int datasheet;
  9.  
  10. cin >> datasheet;
  11.  
  12. while(datasheet--)
  13. {
  14. double cookies_in_box=0,all_cookies=0,how_many_boxes=0;
  15. int people;
  16. const int secs_in_a_day = 86400;
  17.  
  18. cin >> people >> cookies_in_box;
  19.  
  20. int * time_for_cookie = new int [people-1];
  21. int * const time_pointer = time_for_cookie;
  22.  
  23. for(int j=0; j<people; j++)
  24. {
  25. cin >> *(time_for_cookie++);
  26. }
  27.  
  28. time_for_cookie = time_pointer;
  29.  
  30. for( int i=0; i<people; i++)
  31. {
  32. double ammount = floor(secs_in_a_day/time_for_cookie[i]);
  33. all_cookies+=ammount;
  34. }
  35.  
  36. how_many_boxes=ceil(all_cookies/cookies_in_box);
  37.  
  38. cout << how_many_boxes << endl;
  39.  
  40. delete [] time_for_cookie;
  41.  
  42. }
  43. return 0;
  44. }
  45.  
Runtime error #stdin #stdout #stderr 0s 4888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_array_new_length'
  what():  std::bad_array_new_length