#K32962. Taco Time Log Analyzer
Taco Time Log Analyzer
Taco Time Log Analyzer
You are given multiple test cases. In each test case, you are provided with a sequence of log entries. Each log entry is a string that starts with a timestamp in the format \(YYYY-MM-DD\ HH:MM:SS\) followed by additional text (the log message). Your task is to compute the difference in seconds between the timestamp of the first log entry and that of the last log entry for each test case.
Formally, if the timestamp of the first log is \(t_{first}\) and the timestamp of the last log is \(t_{last}\), then you need to calculate:
[ \text{Difference (in seconds)} = t_{last} - t_{first} ]
Print the result for each test case on a new line.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains an integer \(T\), the number of test cases.
- For each test case:
- An integer \(N\) denoting the number of log entries.
- Followed by \(N\) lines, each containing a log entry. Each log entry starts with a timestamp formatted as
YYYY-MM-DD HH:MM:SS
followed by additional text.
outputFormat
For each test case, output a single integer representing the difference in seconds between the first and the last log entry’s timestamps. Each output must be printed on a new line to the standard output (stdout).
## sample4
3
2023-03-26 04:10:00 log entry 1
2023-03-26 05:15:00 log entry 2
2023-03-26 06:10:00 log entry 3
4
2023-03-25 13:45:20 log entry a
2023-03-25 14:00:35 log entry b
2023-03-25 14:45:50 log entry c
2023-03-25 15:45:20 log entry d
2
2023-09-01 00:00:00 log entry A
2023-09-01 00:00:00 log entry B
2
2023-09-01 00:00:00 log entry A
2023-09-01 00:01:00 log entry B
7200
7200
0
60
</p>