日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

A - System Administrator CodeForces - 245A(水题)

發(fā)布時(shí)間:2023/12/15 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 A - System Administrator CodeForces - 245A(水题) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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
Input
2
1 5 5
2 6 4
Output
LIVE
LIVE
Input
3
1 0 10
2 0 10
1 10 0
Output
LIVE
DEAD
Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.

Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
這個(gè)題目乍一看又臭又長(zhǎng),看不太懂。其實(shí)看懂了就是一個(gè)水題。
有兩個(gè)東西,看看傳遞到它的是不是超過(guò)總數(shù)的二分之一,分別輸出就好了。主要是看懂題意。
代碼如下:

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std;const int maxx=1e3+10; struct node{int ping;int ac;int wa; }p[maxx]; int n;int main() {while(scanf("%d",&n)!=EOF){int sum1=0;int sum2=0;int sum1a=0;int sum1w=0;int sum2a=0;int sum2w=0;for(int i=0;i<n;i++){scanf("%d%d%d",&p[i].ping,&p[i].ac,&p[i].wa);if(p[i].ping==1){sum1+=(p[i].ac+p[i].wa);sum1a+=p[i].ac;sum1w+=p[i].wa;}else{sum2+=(p[i].ac+p[i].wa);sum2a+=p[i].ac;sum2w+=p[i].wa;}}if(sum1a*2>=sum1) cout<<"LIVE"<<endl;else cout<<"DEAD"<<endl;if(sum2a*2>=sum2) cout<<"LIVE"<<endl;else cout<<"DEAD"<<endl;} }

努力加油a啊,(o)/~

總結(jié)

以上是生活随笔為你收集整理的A - System Administrator CodeForces - 245A(水题)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。