#C4266. Overdue Task Calculation

    ID: 47785 Type: Default 1000ms 256MiB

Overdue Task Calculation

Overdue Task Calculation

You are given a list of tasks along with a current date. Each task has a unique identifier task_id, a due date due_date in the format YYYY-MM-DD, a status which is either pending or completed, and a completion_date (which may be "None" if the task has not been completed).

Your goal is to determine which tasks are overdue and compute the number of days they are overdue.

A task is considered overdue if:

  • It is pending and its due date is strictly earlier than the current date. The number of overdue days is given by $$days_{overdue} = current\_date - due\_date$$ (in days).
  • It is completed but was finished after its due date. In this case, the overdue days is $$days_{overdue} = completion\_date - due\_date$$ (in days).

If a completed task’s completion date is the same as or earlier than the due date, it is not considered overdue.

inputFormat

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

n
task_1
task_2
...
task_n
current_date

Here, n is an integer representing the number of tasks. Each task is described on its own line in the format:

task_id due_date status completion_date

Note: If completion_date is not available (i.e. the task is pending), the field will be given as None (a string).

outputFormat

The output should be printed to standard output (stdout). For each overdue task, output a line with its task_id and the corresponding days_overdue, separated by a space. The order of tasks in the output should be the same as the input order. If there are no overdue tasks, output nothing.

## sample
3
1 2023-04-01 pending None
2 2023-03-29 completed 2023-04-02
3 2023-04-02 completed 2023-04-01
2023-04-03
1 2

2 4

</p>