#C4796. Tracking Package Journey

    ID: 48373 Type: Default 1000ms 256MiB

Tracking Package Journey

Tracking Package Journey

You are given a log of a package's journey through several checkpoints. Each checkpoint is described by a location name and a timestamp. Your task is to compute the total travel time, which is the difference between the timestamp of the last checkpoint and the first checkpoint, and to identify any missing checkpoints from an expected list. If no checkpoints are missing, output All checkpoints accounted for; otherwise, list the missing checkpoint names separated by a space.

Note: The input and output are handled via standard input (stdin) and standard output (stdout) respectively.

inputFormat

The first line of input contains an integer n, representing the number of recorded checkpoints. The next n lines each contain a checkpoint description with a location (string) and a timestamp (integer) separated by a space. The following line contains a space-separated list of expected checkpoint names.

outputFormat

Output consists of two lines: the first line is the total travel time computed as the difference between the timestamp of the last and the first checkpoint, and the second line is either 'All checkpoints accounted for' if no checkpoints are missing, or a space-separated string of the missing checkpoint names.## sample

3
Start 5
Midway 25
End 45
Start Midway End
40

All checkpoints accounted for

</p>