精 挑 细 选
时间限制:
3000 ms | 内存限制:
65535 KB
难度:1
- 描述
-
小王是公司的仓库管理员,一天,他接到了这样一个任务:从仓库中找出一根钢管。这听起来不算什么,但是这根钢管的要求可真是让他犯难了,要求如下:
1、 这根钢管一定要是仓库中最长的;
2、 这根钢管一定要是最长的钢管中最细的;
3、 这根钢管一定要是符合前两条的钢管中编码最大的(每根钢管都有一个互不相同的编码,越大表示生产日期越近)。
相关的资料到是有,可是,手工从几百份钢管材料中选出符合要求的那根……
要不,还是请你编写个程序来帮他解决这个问题吧。- 输入
-
第一行是一个整数N(N<=10)表示测试数据的组数)
每组测试数据的第一行 有一个整数m(m<=1000),表示仓库中所有钢管的数量,
之后m行,每行三个整数,分别表示一根钢管的长度(以毫米为单位)、直径(以毫米为单位)和编码(一个9位整数)。 - 输出
-
对应每组测试数据的输出只有一个9位整数,表示选出的那根钢管的编码,
每个输出占一行 - 样例输入
-
222000 30 1234567892000 20 98765432143000 50 8721984423000 45 7524981242000 60 7651287423000 45 652278122
- 样例输出
-
987654321752498124
查看代码---运行号:252254----结果:Accepted
运行时间:
2012-10-05 14:37:13 | 运行人:
huangyibiao
01.
#include <cstdio>
02.
#include <iostream>
03.
using
namespace
std;
04.
int
main()
05.
{
06.
int
t;
07.
scanf
(
"%d "
, &t);
08.
09.
while
(t--)
10.
{
11.
int
numOfPiles;
12.
scanf
(
"%d "
, &numOfPiles);
13.
14.
int
maxLen = 0, minThin = 10000, maxNo = 0;
15.
int
len, thin, no;
16.
for
(
int
i = 0; i < numOfPiles; i++)
17.
{
18.
scanf
(
"%d%d%ld"
, &len, &thin, &no);
19.
if
(maxLen < len)
20.
{
21.
maxLen = len;
22.
minThin = thin;
23.
maxNo = no;
24.
}
25.
if
(maxLen == len && minThin > thin)
26.
{
27.
minThin = thin;
28.
maxNo = no;
29.
}
30.
if
(maxLen == len && thin == minThin && maxNo < no)
31.
{
32.
maxNo = no;
33.
}
34.
}
35.
printf
(
"%ld\n"
, maxNo);
36.
}
37.
return
0;
38.
}