HDU 3279 Nth Largest Value
2016-04-04 18:26
561 查看
Description
For this problem, you will write a program that prints the Nth largest value in a fixed sized array of integers. To make things simple, Nwill be 3 and the array will always be have 10 decimal
integer values.
Input
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing the data set number, followed
by a space,followed by 10 space separated decimal integers whose values are between 1 and 1000 inclusive.
Output
For each data set, generate one line of output with the following values: The data set number as a decimal integer, a space, and the 3 rdlargest value of the corresponding 10 integers.
Sample Input
4
1 1 2 3 4 5 6 7 8 9 1000
2 338 304 619 95 343 496 489 116 98 127
3 931 240 986 894 826 640 965 833 136 138
4 940 955 364 188 133 254 501 122 768 408
Sample Output
1 8
2 489
3 931
4 768
不知道出这种题是要干嘛。
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long LL;
const int low(int x){ return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int T, n, a[10];
int main()
{
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = 0; i < 10; i++) scanf("%d", &a[i]);
sort(a, a + 10);
printf("%d %d\n", n, a[7]);
}
return 0;
}
For this problem, you will write a program that prints the Nth largest value in a fixed sized array of integers. To make things simple, Nwill be 3 and the array will always be have 10 decimal
integer values.
Input
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing the data set number, followed
by a space,followed by 10 space separated decimal integers whose values are between 1 and 1000 inclusive.
Output
For each data set, generate one line of output with the following values: The data set number as a decimal integer, a space, and the 3 rdlargest value of the corresponding 10 integers.
Sample Input
4
1 1 2 3 4 5 6 7 8 9 1000
2 338 304 619 95 343 496 489 116 98 127
3 931 240 986 894 826 640 965 833 136 138
4 940 955 364 188 133 254 501 122 768 408
Sample Output
1 8
2 489
3 931
4 768
不知道出这种题是要干嘛。
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long LL;
const int low(int x){ return x&-x; }
const int INF = 0x7FFFFFFF;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int T, n, a[10];
int main()
{
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = 0; i < 10; i++) scanf("%d", &a[i]);
sort(a, a + 10);
printf("%d %d\n", n, a[7]);
}
return 0;
}
相关文章推荐
- Leetcode232. Implement Queue using Stacks[栈实现队列]
- ios--uitextfield动态限制输入的字数(解决方式)
- 3.30课·········Marquee标签
- Hive分析窗口函数之LAG,LEAD,FIRST_VALUE和LAST_VALUE
- CALayer 的基本概念和基本使用
- This certificate has an invalid issuer
- BlockingQueue队列学习
- 关于requirejs中的define的原理理解
- 【HDU 2604】 Queuing
- cryptoAPI接口(五)------------获取证书--演示 CryptUIDlgViewCertificate
- key-value store
- String StringBuilder StringBuffer
- package-query: requires pacman<4.3(solved)
- SQuirreL 连接 hive
- unix环境高级编程(第三版)中apue.h文件的配置问题
- Espresso自动化测试(十三)- UiAutomator2与Espresso的结合
- Arduino在ROS中的应用
- Activity中UI框架基本概念
- EasyUI Datagrid JSON对象内嵌对象的取值问题
- SIP请求消息类型与应答码