#K41607. Process Log Latencies

    ID: 26903 Type: Default 1000ms 256MiB

Process Log Latencies

Process Log Latencies

You are given a series of log entries, each in the format: (timestamp\ service_name\ latency), where:

  • timestamp is in HH:MM:SS format.
  • service_name is a string identifying the service.
  • latency is an integer representing the latency in milliseconds.

Your task is to compute two quantities:

  1. A JSON dictionary containing the total latency for each service.
  2. The service that recorded the highest single latency.

Input is provided line by line via standard input. The log entries end when a line containing only the word "end" is encountered. If no logs are provided (i.e. the first line is "end"), output an empty dictionary and None for the highest latency service.

inputFormat

Input is read from standard input and consists of multiple lines. Each line (except the terminating line) is formatted as follows:

(timestamp\ service_name\ latency)

  • timestamp: A string in HH:MM:SS format.
  • service_name: A string without spaces.
  • latency: An integer (in milliseconds).
The input terminates with a line containing only the word "end".

outputFormat

The output should be printed to standard output and consists of two lines:

  1. A JSON dictionary (as a single line) representing the total latencies for each service.
  2. A single line containing the name of the service with the highest single log latency. Print None if there are no logs.
## sample
15:32:10 serviceA 120
15:32:15 serviceB 80
15:32:20 serviceA 150
15:32:30 serviceC 200
15:32:35 serviceB 50
15:32:40 serviceC 100
15:32:45 serviceA 250
end
{"serviceA": 520, "serviceB": 130, "serviceC": 300}

serviceA

</p>