#K77372. Detect Poorly Performing Servers
Detect Poorly Performing Servers
Detect Poorly Performing Servers
You are given data for several servers. Each server is represented by a line of input containing a server ID, a threshold value, and a series of latency measurements. Your task is to identify which servers are performing poorly. A server is performing poorly if the average of its latency measurements is strictly greater than the threshold given for that server.
If no server meets the criteria for poor performance or if the list is empty, output the phrase "All servers are healthy".
Technical Details:
- The first line of input contains an integer n, the number of servers.
- Each of the next n lines contains a server description. The line starts with the server ID (a string), followed by a threshold (a floating-point number), and then a sequence of floating-point latency values.
- The average latency is computed as \(\frac{\text{sum of latencies}}{\text{number of latency values}}\).
- If \(\text{average latency} > \text{threshold}\), then the server is considered poorly performing.
Output the IDs of the poorly performing servers in the order they appear in the input, separated by a single space. If no servers are poorly performing, output "All servers are healthy".
inputFormat
The input is given via standard input (stdin) and consists of multiple lines.
- The first line contains a single integer \(n\) (where \(n \ge 0\)) — the number of servers.
- The next \(n\) lines each contain a description of a server. Each description has the following format:
server_id threshold latency_1 latency_2 ... latency_k
If \(n = 0\), then there is no additional input and you should output "All servers are healthy".
outputFormat
The output should be printed to standard output (stdout) in a single line.
- If there is at least one poorly performing server, print their server IDs separated by a single space (in the order they appear in the input).
- If no server is poorly performing or if there are no servers, output the exact string:
All servers are healthy
.
3
server1 150.0 120.5 130.2 110.0
server2 200.0 100.0 120.0 140.0
server3 180.0 85.0 95.0 105.0
All servers are healthy