A. System Administrator

本文介绍了一种用于评估服务器健康状态的算法,通过分析Ping命令发送和接收的数据包数量,判断服务器是否处于活动状态。该算法适用于系统管理员监测服务器性能,确保至少一半的数据包能成功到达目标服务器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers’ performance, Polycarpus executes commands “ping a” and “ping b”. Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y ≥ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.

Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is “alive” or not. Polycarpus thinks that the server is “alive”, if at least half of the packets that we send to this server reached it successfully along the network.

Help Polycarpus, determine for each server, whether it is “alive” or not by the given commands and their results.

Input
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers ti, xi, yi (1 ≤ ti ≤ 2; xi, yi ≥ 0; xi + yi = 10). If ti = 1, then the i-th command is “ping a”, otherwise the i-th command is “ping b”. Numbers xi, yi represent the result of executing this command, that is, xi packets reached the corresponding server successfully and yi packets were lost.

It is guaranteed that the input has at least one “ping a” command and at least one “ping b” command.

Output
In the first line print string “LIVE” (without the quotes) if server a is “alive”, otherwise print “DEAD” (without the quotes).

In the second line print the state of server b in the similar format.

Examples
inputCopy
2
1 5 5
2 6 4
outputCopy
LIVE
LIVE
inputCopy
3
1 0 10
2 0 10
1 10 0
outputCopy
LIVE
DEAD

#include <iostream>
using namespace std;

int main()
{
    int n;
    while(cin >> n)
    {
        int asumx = 0;
        int asumy = 0;
        int bsumx = 0;
        int bsumy = 0;
        for(int i = 0; i < n; ++i)
        {
            int t, x, y;
            cin >> t >> x >> y;
            if(t == 1)
            {
                asumx += x;
                asumy += y;
            }
            else
            {
                bsumx += x;
                bsumy += y;
            }
        }
        if(asumx >= asumy)
            cout << "LIVE" << '\n';
        else
            cout << "DEAD" << '\n';
        if(bsumx >= bsumy)
            cout << "LIVE" << '\n';
        else
            cout << "DEAD" << '\n';
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值