Statistics

Problem Statement for "Salary"

Problem Statement

Often employees at a company time stamp their arrivals and departures, so when the month is over the boss can check how much each employee has worked. Given the time stamps for a single employee during a single day as well as his (or her) hourly wage, calculate how much the employee has earned that day.

The time stamps are given in the format "hh:mm:ss" (quotes for clarity only) where hh is the hour (between 00 and 23 inclusive), mm is the minute (between 00 and 59 inclusive) and ss is the second (between 00 and 59 inclusive). All these numbers have exactly two digits. The arrival time stamps are inclusive, and the departure time stamps are exclusive, so an employee arriving at 09:00:00 one day and departing 17:30:00 the same day has worked exactly 8 hours 30 minutes 0 seconds during that interval.

An employee working during evenings (between 18:00:00 and 23:59:59, inclusive) or nights (between 00:00:00 and 05:59:59, inclusive) gets paid one and a half times as much during that period.

Create a class Salary containing the method howMuch which takes a String[], arrival, and a String[], departure, the arrival and departures times of an employee, respectively, as well an int wage, the hourly wage (in cents). Your method should return an int representing the total amount (in cents) the employee earned during the time he or she worked. The amount should be rounded down to the largest integer less than or equal to the actual amount. Element i in arrival corresponds to element i in departure.

Definition

Class:
Salary
Method:
howMuch
Parameters:
String[], String[], int
Returns:
int
Method signature:
int howMuch(String[] arrival, String[] departure, int wage)
(be sure your method is public)

Constraints

  • arrival will contain between 1 and 10 elements, inclusive.
  • departure will contain between 1 and 10 elements, inclusive.
  • arrival will contain the same number of elements as departure.
  • All elements in arrival and departure will be in the form "hh:mm:ss" (quotes for clarity only) satisfying the constraints given above.
  • All time stamps will be strictly increasing; that is, arrival[0]
  • wage will be between 100 and 10000, inclusive.

Examples

  1. {"08:00:00","13:00:00","19:27:32"}

    {"12:00:00","17:00:00","20:48:10"}

    1000

    Returns: 10015

    This employee worked 4 hours, took a break and then worked 4 more hours. Later he got back to work and worked 1 hour, 20 minutes and 38 seconds overtime. The salary becomes (4+4)*1000 + (1+20/60+38/3600)*1000*1.5 = 10015.83333 which is rounded down to 10015.

  2. {"01:05:47","16:48:12"}

    {"09:27:30","21:17:59"}

    2000

    Returns: 33920

  3. {"00:00:00"}

    {"23:59:59"}

    10000

    Returns: 299995

  4. {"10:00:00"}

    {"18:00:00"}

    10000

    Returns: 80000

    Notice that 18:00:00 is exclusive, so the last second was not overtime.

  5. {"00:11:13","02:59:22","04:42:01","06:33:45","08:22:30","09:21:27","11:15:50","12:40:14","13:55:51"}

    {"01:48:51","03:22:59","06:33:07","06:45:47","08:23:15","09:34:07","11:48:51","12:47:18","16:01:53"}

    9998

    Returns: 87238

  6. {"01:15:19","06:05:29","08:54:03","12:15:52"}

    {"03:41:48","06:59:11","11:41:51","13:51:02"}

    9892

    Returns: 88433

  7. {"00:41:50"}

    {"02:04:22"}

    6452

    Returns: 13312

  8. {"00:02:24","00:15:34","01:49:50","06:00:30","06:32:40","07:20:20","10:08:24"}

    {"00:12:09","01:40:25","03:05:27","06:02:29","06:37:55","09:47:09","10:45:26"}

    9082

    Returns: 67571

  9. {"02:28:10","06:38:17","11:48:29"}

    {"03:56:36","08:25:27","12:08:15"}

    9815

    Returns: 42463

  10. {"01:36:08","03:08:26","04:19:14","05:08:29","07:49:55","10:01:50","11:18:26"}

    {"02:35:30","03:40:11","04:20:01","05:35:37","07:56:52","10:26:23","11:25:52"}

    8731

    Returns: 31647

  11. {"00:15:03"}

    {"08:01:33"}

    5053

    Returns: 53812

  12. {"00:21:14","01:05:03","06:25:05","11:37:53","12:21:50","12:46:27"}

    {"00:38:07","01:52:26","11:24:28","11:46:49","12:32:00","12:59:48"}

    6636

    Returns: 47362

  13. {"01:39:56","04:20:00","05:24:34"}

    {"03:46:59","04:51:00","05:34:15"}

    6785

    Returns: 28451

  14. {"00:07:24","02:00:10","03:32:10","03:52:12","05:39:53","06:07:53","07:31:59","12:32:33","12:54:34","15:57:53"}

    {"00:52:54","02:06:35","03:39:16","04:31:45","05:40:55","06:14:55","08:30:55","12:39:20","14:38:50","15:59:03"}

    8381

    Returns: 45757

  15. {"00:04:14","01:34:15","01:56:13","02:44:05","03:09:59","04:07:06","08:01:57","12:17:35","14:45:49","16:26:50"}

    {"00:31:17","01:35:12","02:12:33","02:52:08","03:45:29","07:44:13","09:26:57","14:33:37","14:53:15","18:33:03"}

    6703

    Returns: 86759

  16. {"00:21:34","12:23:06"}

    {"10:49:19","16:45:30"}

    9740

    Returns: 171970

  17. {"04:07:12","06:28:22","11:57:16","13:34:13","16:48:52"}

    {"06:06:23","10:22:45","11:58:27","14:16:03","17:15:19"}

    9830

    Returns: 78547

  18. {"00:55:54","03:31:17"}

    {"03:19:13","08:10:48"}

    8076

    Returns: 76567

  19. {"00:08:39","02:46:35","03:48:51","04:05:42","04:31:49"}

    {"02:03:17","03:13:36","03:54:31","04:19:13","05:17:05"}

    7087

    Returns: 36515

  20. {"03:10:51","05:39:23","07:03:27","07:56:49","09:46:49","09:57:30","11:45:30","15:36:37"}

    {"03:51:33","06:09:58","07:13:54","09:39:21","09:56:07","11:05:02","15:08:16","15:54:58"}

    6863

    Returns: 58664

  21. {"00:52:29","05:18:12","07:18:21","07:24:08","08:10:15","09:52:45","12:48:13","16:27:38","17:26:41"}

    {"03:50:29","06:13:29","07:20:41","07:51:34","09:19:25","10:53:08","14:43:09","17:22:17","18:37:51"}

    6359

    Returns: 80777

  22. {"00:24:33","05:10:26","05:53:25","08:02:43","10:23:31","12:00:12","12:26:44","13:56:15"}

    {"00:38:43","05:10:37","06:58:44","08:46:44","11:40:59","12:03:11","13:33:02","14:58:26"}

    8424

    Returns: 48168

  23. {"00:03:44","04:46:45","06:19:18","06:58:03","07:40:47","08:09:27","12:08:24"}

    {"04:01:46","05:13:11","06:34:09","07:03:50","07:50:02","11:22:39","12:14:36"}

    7499

    Returns: 78237

  24. {"01:26:33","02:44:28","04:21:58","06:23:34","08:43:52","11:19:35","15:55:03","18:05:55","18:42:51"}

    {"02:08:48","02:56:03","05:41:40","07:05:11","09:55:19","12:43:16","16:36:19","18:20:30","18:57:35"}

    7308

    Returns: 58743

  25. {"03:08:26","05:44:57","09:05:54","10:37:37","11:42:09","12:43:57"}

    {"04:05:57","06:24:26","09:51:22","10:54:12","12:39:40","13:44:20"}

    9740

    Returns: 50848

  26. {"00:26:23","01:18:00","04:51:11"}

    {"00:30:35","02:25:17","05:04:31"}

    5391

    Returns: 11431

  27. {"04:41:33","05:11:52","06:22:02","07:23:29","08:27:18","11:04:14","12:44:52","13:05:52","16:08:23"}

    {"04:57:43","05:30:20","06:48:39","08:00:31","10:04:26","12:30:23","12:55:28","15:56:18","16:45:57"}

    9079

    Returns: 78303

  28. {"00:03:46","01:30:21","02:17:04","02:47:09"}

    {"00:52:16","01:36:05","02:29:24","04:02:30"}

    8574

    Returns: 30419

  29. {"00:43:25","02:06:06","04:18:11","05:34:21","07:04:48","10:19:57","11:06:01","13:13:22","13:44:34","15:10:28"}

    {"01:57:13","02:38:17","05:02:56","06:58:17","09:13:40","10:37:35","11:14:34","13:37:56","14:08:02","18:12:07"}

    6584

    Returns: 78311

  30. {"00:39:28","03:51:24","04:56:16","05:54:24","08:08:47","09:56:36","13:13:28","15:57:48","16:37:19"}

    {"02:43:31","04:36:10","05:17:47","07:40:56","09:54:38","11:58:58","14:56:50","15:57:51","17:45:57"}

    6719

    Returns: 89037

  31. {"01:14:44","04:18:37","05:44:27"}

    {"03:45:31","05:44:13","05:49:44"}

    9599

    Returns: 57993

  32. {"02:30:45","03:11:25","04:20:22","05:01:06","06:40:51","08:05:22","11:19:23","13:45:15","14:30:22"}

    {"02:57:58","04:08:33","05:00:36","06:27:59","07:05:40","10:30:40","11:29:57","13:46:22","21:44:09"}

    6625

    Returns: 113824

  33. {"00:40:45","02:30:19","03:43:22","05:08:24","07:39:52","12:08:15","14:47:37","16:12:58","17:14:47","19:40:53"}

    {"01:14:47","03:08:57","04:27:12","06:59:37","10:21:55","12:17:15","14:59:47","16:38:51","18:04:58","19:44:10"}

    7293

    Returns: 70311

  34. {"02:46:35","06:19:05","08:12:48","09:39:29","11:08:03","16:20:38","16:25:19","17:20:09","20:09:58"}

    {"03:06:25","07:25:02","09:13:05","10:25:00","15:46:15","16:24:30","16:54:49","18:22:33","21:23:09"}

    7486

    Returns: 86902

  35. {"00:49:38","06:42:57","09:32:06","11:32:22","17:25:50"}

    {"02:34:40","09:12:36","09:39:20","16:21:43","21:13:14"}

    9053

    Returns: 139989

  36. {"01:27:05","04:11:22","08:26:48","10:42:14","12:50:45","13:50:43"}

    {"02:49:42","04:35:17","09:39:29","11:55:26","13:48:27","13:55:35"}

    5087

    Returns: 31221

  37. {"00:48:31","01:56:02","02:32:00","04:54:35"}

    {"01:10:57","02:31:09","04:02:06","09:20:14"}

    7093

    Returns: 61452

  38. {"00:01:50","02:33:56","14:39:05","16:04:34"}

    {"01:21:18","12:10:02","15:18:42","17:25:47"}

    5328

    Returns: 81622

  39. {"01:47:30","03:18:07","05:36:43","06:34:28","08:55:50","12:06:04","15:09:34","17:42:29"}

    {"03:11:31","04:27:32","06:17:09","06:50:11","09:27:25","12:50:13","16:07:35","17:47:49"}

    6671

    Returns: 48589

  40. {"00:44:09","04:13:36","05:57:29","07:14:54","09:05:16","12:05:06","12:37:03","13:22:44","14:08:10"}

    {"01:40:02","04:44:16","06:14:24","07:58:59","11:23:03","12:13:28","13:18:15","13:44:23","18:50:49"}

    8282

    Returns: 97885

  41. {"03:56:44","10:29:07"}

    {"09:52:32","13:49:29"}

    9904

    Returns: 101978

  42. {"01:01:35","03:55:26","05:20:19"}

    {"01:43:00","04:44:09","08:45:28"}

    5913

    Returns: 35496

  43. {"01:45:13","02:47:02","06:36:03","07:50:38","08:25:47","08:44:54","08:50:25","10:58:26","13:21:38"}

    {"02:45:48","04:20:48","06:36:47","08:24:52","08:26:26","08:47:04","10:18:11","13:05:41","16:42:54"}

    6946

    Returns: 79368

  44. {"01:19:24","03:44:55","04:28:34","08:24:37","09:09:45","10:55:17","11:39:31","12:26:49","14:03:52"}

    {"02:48:45","03:49:37","06:55:23","08:47:20","09:34:04","11:00:15","12:03:30","12:45:41","19:46:38"}

    6090

    Returns: 83690

  45. {"00:22:38"}

    {"00:25:39"}

    9996

    Returns: 753

  46. {"02:34:52","03:22:51","04:07:58","07:45:08","10:12:15","11:27:06","12:57:47","13:41:39","18:35:48","19:39:25"}

    {"03:20:55","03:38:24","04:11:27","08:22:37","11:04:27","12:38:36","13:12:04","16:56:41","18:43:45","20:40:10"}

    5330

    Returns: 50739

  47. {"01:09:08","02:11:27","03:12:56","04:52:41"}

    {"01:31:46","03:11:37","03:19:19","05:35:18"}

    5936

    Returns: 19559

  48. {"02:01:02","02:38:12","03:48:21","08:17:47","10:09:30"}

    {"02:10:42","03:11:15","07:13:40","09:34:50","10:44:13"}

    7799

    Returns: 58100

  49. {"00:52:58","01:19:34","01:57:46","04:19:37","07:11:29"}

    {"01:06:13","01:41:38","02:44:41","05:34:17","08:34:26"}

    6314

    Returns: 33495

  50. {"00:43:55","03:11:44","06:56:19","08:15:39","13:21:16","15:34:05","16:57:33","18:00:11"}

    {"02:33:51","06:18:06","07:52:34","09:32:14","13:52:45","16:28:54","17:48:47","19:50:55"}

    9948

    Returns: 144555

  51. {"00:24:17","01:23:40","03:04:43","05:54:25","06:20:51","06:39:56","08:10:20","10:02:27","13:50:13","14:52:47"}

    {"00:42:59","02:05:53","05:00:43","06:11:10","06:32:10","06:52:26","08:51:15","13:45:18","14:37:27","16:19:07"}

    7791

    Returns: 91682

  52. {"01:40:31","04:00:40","04:43:06","06:50:17","08:07:44","08:31:49","10:35:27","13:10:32","14:14:07","14:30:36"}

    {"01:43:37","04:31:42","05:57:07","06:56:18","08:17:01","09:41:26","12:48:15","14:08:10","14:25:23","16:10:35"}

    8762

    Returns: 80146

  53. {"00:13:49","02:28:38","05:16:39","08:13:39","10:32:31","12:27:05"}

    {"00:40:10","05:04:14","08:00:38","09:14:49","10:53:10","14:48:59"}

    9563

    Returns: 108747

  54. {"00:56:21","02:01:57","03:31:25","04:43:43","08:05:17","09:43:04","10:18:12","11:32:14"}

    {"02:00:35","02:38:17","04:41:40","07:51:06","08:38:20","09:56:10","10:27:10","13:16:19"}

    7322

    Returns: 78217

  55. {"01:33:07","02:53:08","08:20:04","08:58:48"}

    {"01:45:08","04:36:29","08:32:30","10:16:47"}

    6087

    Returns: 26728

  56. {"01:48:15","02:37:15"}

    {"02:27:14","04:02:35"}

    8281

    Returns: 25736

  57. {"00:54:52","04:44:37","07:10:41"}

    {"04:20:58","05:45:10","07:17:20"}

    6712

    Returns: 45487

  58. {"01:05:58","05:58:54","09:37:36","10:24:38","12:10:12","15:08:53","16:24:15","16:57:48","17:57:12","19:09:26"}

    {"01:37:45","08:59:28","10:05:23","11:31:33","13:46:41","15:13:26","16:33:58","17:33:07","18:26:42","19:24:16"}

    8937

    Returns: 79637

  59. {"00:08:14","03:28:33","05:02:40"}

    {"00:36:09","03:53:46","05:02:43"}

    7962

    Returns: 10586

  60. {"03:30:31","06:25:49","10:09:32","16:01:45"}

    {"06:08:30","08:03:37","14:26:15","16:06:30"}

    5429

    Returns: 53565

  61. {"02:56:41"}

    {"04:19:51"}

    8132

    Returns: 16907

  62. {"02:38:54","04:56:56","05:16:37","06:56:12","14:10:22","16:39:46"}

    {"03:40:45","05:11:03","06:31:09","13:30:50","15:28:14","17:01:21"}

    8057

    Returns: 94570

  63. {"00:07:17","02:56:56","06:30:25","06:52:29","08:05:54","09:07:28","11:38:31","12:21:50","16:56:34"}

    {"00:47:56","03:12:00","06:50:30","07:36:46","08:30:02","11:33:17","12:10:44","14:45:23","17:35:32"}

    7175

    Returns: 63693

  64. {"02:49:14","05:45:58","06:41:07","09:12:08","11:49:50","12:11:10","12:58:17","16:20:25","17:02:41","19:32:55"}

    {"04:14:58","06:15:55","08:50:42","09:40:51","12:07:36","12:40:58","16:01:22","16:44:58","17:39:21","20:02:03"}

    8689

    Returns: 95496

  65. {"22:19:46"}

    {"23:12:46"}

    5320

    Returns: 7049

  66. { "00:00:00" }

    { "23:59:59" }

    10000

    Returns: 299995

  67. { "08:00:00", "13:00:00", "19:27:32" }

    { "12:00:00", "17:00:00", "20:48:10" }

    1000

    Returns: 10015

  68. { "22:19:46" }

    { "23:12:46" }

    5320

    Returns: 7049

  69. { "03:00:00" }

    { "06:00:00" }

    10000

    Returns: 45000

  70. { "00:00:00" }

    { "23:59:59" }

    100

    Returns: 2999

  71. { "05:59:59" }

    { "06:00:00" }

    10000

    Returns: 4

  72. { "03:02:00" }

    { "21:00:00" }

    218

    Returns: 4567

  73. { "05:59:59" }

    { "23:00:00" }

    10000

    Returns: 195004

  74. { "00:00:00" }

    { "00:00:01" }

    3600

    Returns: 1

  75. { "18:00:00" }

    { "18:00:01" }

    7200

    Returns: 3

  76. { "00:00:00" }

    { "01:00:00" }

    999

    Returns: 1498

  77. { "00:00:00" }

    { "01:00:00" }

    1000

    Returns: 1500

  78. { "05:59:58" }

    { "05:59:59" }

    10000

    Returns: 4

  79. { "12:00:00" }

    { "13:00:00" }

    8189

    Returns: 8189

  80. { "00:00:01", "00:00:05", "00:00:09", "04:09:59", "06:06:06", "09:59:59", "12:59:00", "14:00:00", "17:30:30", "20:00:01" }

    { "00:00:02", "00:00:07", "00:00:10", "05:59:59", "07:07:07", "10:00:01", "13:14:15", "16:59:59", "19:00:59", "23:59:59" }

    342

    Returns: 5143

  81. { "05:59:00", "17:58:32" }

    { "06:00:01", "18:01:21" }

    9999

    Returns: 834


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: