#K78322. Compute Productive Work Time
Compute Productive Work Time
Compute Productive Work Time
Given a series of time-stamped events representing work and break periods, compute the total productive time worked by an employee in minutes.
The events are provided in chronological order and include the following commands:
start t
: Employee starts working at time \( t \).break t
: Employee begins a break at time \( t \). The work segment ends at this moment.return t
: Employee returns from a break at time \( t \). A new work segment begins immediately.stop t
: Employee stops working at time \( t \).
The total productive time is the sum of all work periods excluding break times.
inputFormat
The input is read from stdin and follows this format:
- The first line contains an integer \( n \) which is the number of events.
- The next \( n \) lines each contain an event represented as two tokens separated by a space: an action (one of
start
,break
,return
, orstop
) and a non-negative integer representing time in minutes.
outputFormat
Output the total productive time worked in minutes as a single integer to stdout.
## sample4
start 0
break 30
return 45
stop 90
75