#K2836. Working Hours Calculation

    ID: 24825 Type: Default 1000ms 256MiB

Working Hours Calculation

Working Hours Calculation

You are given a log of employee events. Each event is represented by four fields: an integer employee ID, a date in the format YYYY-MM-DD, a time in the format HH:MM:SS, and an event type which can be either "check-in" or "check-out".

Your task is to compute the total number of hours each employee worked by matching check-in and check-out events. For each matching pair, the working hours are given by the formula below:

\[ \text{working hours} = \frac{\text{seconds between check-out and check-in}}{3600} \]

If an employee has an unmatched check-in (i.e. a check-in without a subsequent check-out), that period is ignored. Finally, output the result for each employee in increasing order of employee ID with the total hours rounded to two decimal places.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer m, the number of log entries.
  • The next m lines each contain a log record with four pieces of data separated by spaces:
    • An integer representing the employee ID
    • A date in the format YYYY-MM-DD
    • A time in the format HH:MM:SS
    • A string which is either "check-in" or "check-out"

outputFormat

For each employee with valid check-in/check-out pairs, output one line to standard output (stdout) containing the employee ID and the total hours worked, rounded to two decimal places. The format for each line is:

ID hours

Lines must be sorted in ascending order by the employee ID.

## sample
6
1 2023-01-01 08:00:00 check-in
1 2023-01-01 16:00:00 check-out
2 2023-01-01 09:30:00 check-in
2 2023-01-01 17:45:00 check-out
3 2023-01-01 10:15:00 check-in
3 2023-01-01 18:30:00 check-out
1 8.00

2 8.25 3 8.25

</p>