TimeCard
SRM 257 · 2005-08-08 · by dgoodman
Problem Statement
hh:mm,xxwhere hh is the 2 digit representation of the hour, mm is the 2 digit representation of the minute, and xx is either am or pm. The ':' and ',' are literal. "12:00,am" denotes midnight, while "12:00,pm" denotes noon.
The difference between that time I punch in and the time I punch out is the amount of time I have worked so, for example, if I punch in at 03:33pm and punch out at 03:34pm I have worked 1 minute.
No shift is allowed to be more than 20 hours long. This is my last shift of the
week and I am supposed to work 40 hours during the week.
Create a class TimeCard that contains a method leave that is given a
The elements of time alternate: punch in time, punch out time, punch in time, ... with the final element being the time I just punched in on my final shift.
Constraints
- time will contain an odd number of elements between 1 and 49 inclusive.
- Each element of time will be formatted as above.
- In each element of time hh will be between 01 and 12 inclusive.
- In each element of time mm will be between 00 and 59 inclusive.
- time will contain no shift that exceeds 20 hours in duration.
{"03:00,pm"}
Returns: "BELOW 40"
This is my one and only shift, and I am only allowed to work 20 hours on a shift.
{"09:00,am","05:00,pm","09:00,am","05:00,pm",
"09:00,am","05:00,pm","09:00,am","05:00,pm","09:00,am"}
Returns: "05:00,pm"
I have worked 4 previous shifts of 8 hours, so I need 8 hours on this shift to make 40.
{"12:00,am","08:00,pm","12:00,am","08:00,pm","12:00,am"}
Returns: "12:00,am"
I have already worked 2 shifts of 20 hours so I already have exactly 40 hours. I should go home immediately.
{"12:00,pm","08:00,pm","12:00,am","08:00,pm","12:00,am"}
Returns: "12:00,pm"
{"09:00,am","04:31,pm","09:00,am","04:31,pm",
"09:00,am","05:00,pm","09:00,am","05:00,pm","03:53,am"}
Returns: "12:51,pm"
{"08:47,pm","03:50,pm","12:24,am"}
Returns: "BELOW 40"
{"09:51,pm","04:48,am","04:07,pm","08:49,pm","08:12,am","10:31,pm","11:51,am","06:10,pm","12:00,pm","09:10,pm","11:54,am","05:58,am","04:52,am"} {"05:47,pm","09:48,pm","07:37,am","04:48,pm","07:12,am","05:44,pm","09:09,pm","12:15,am","08:16,am","02:19,pm","10:16,am","11:49,am","12:12,pm"} {"06:58,pm","05:27,am","07:07,pm"} {"10:39,am","07:35,pm","07:20,am","04:43,pm","04:02,am","05:04,pm","01:42,pm","09:59,pm","04:16,am"} {"04:40,am"} {"02:17,pm","12:53,am","05:48,pm","11:09,pm","02:09,pm","03:07,pm","05:09,pm","06:22,pm","02:36,am","07:47,pm","12:00,am"} {"09:45,am"} {"03:23,pm","08:49,am","05:17,pm","07:07,pm","06:25,pm","03:34,am","12:34,pm","04:41,pm","04:09,am","06:18,am","08:16,pm","05:11,am","08:44,am"} {"03:08,pm","04:47,pm","01:50,pm","04:10,pm","04:40,pm"}
Submissions are judged against all 65 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TimeCard with a public method string leave(vector<string> time) · 65 test cases · 2 s / 256 MB per case