湖南大学ACM程序设计新生杯大赛(同步赛)G-The heap of socks【排序】
2017-12-24 18:42
417 查看
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
BSD is a lazy boy. He doesn’t want to wash his socks, but he will have a data structure called ‘socks heap’.By maintaining this structure, he can quickly pick out two of the most smelless socks from millions of socks everyday. As one of his good friends, you know the data structure of BSD, and want to predict ‘the air pollution level’ of a certain day. Of course, it’s BSD’s socks that pollute the air.
We will enter numbers that indices for ‘socks smell level’ and expect you to output the total amount of pollution that he will wear on the day of BSD design.
输入描述:
First line contain an integer T 1<T<=10 ,means the sum of test cases.
for every test cases,we will firstly give N(1<N<1000000) in a single line,means the count of socks.Next line Contains N numbers (you can use int to save all of them) ,means ‘smell level’ for every socks.
输出描述:
please putout answer in a single line for every test cases.
示例1
输入
3
5
1 1 2 3 5
3
1 4 7
3
200 4 10000
输出
2
5
204
题意:找出两个臭味最小的袜子 。
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
BSD is a lazy boy. He doesn’t want to wash his socks, but he will have a data structure called ‘socks heap’.By maintaining this structure, he can quickly pick out two of the most smelless socks from millions of socks everyday. As one of his good friends, you know the data structure of BSD, and want to predict ‘the air pollution level’ of a certain day. Of course, it’s BSD’s socks that pollute the air.
We will enter numbers that indices for ‘socks smell level’ and expect you to output the total amount of pollution that he will wear on the day of BSD design.
输入描述:
First line contain an integer T 1<T<=10 ,means the sum of test cases.
for every test cases,we will firstly give N(1<N<1000000) in a single line,means the count of socks.Next line Contains N numbers (you can use int to save all of them) ,means ‘smell level’ for every socks.
输出描述:
please putout answer in a single line for every test cases.
示例1
输入
3
5
1 1 2 3 5
3
1 4 7
3
200 4 10000
输出
2
5
204
题意:找出两个臭味最小的袜子 。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define ll long long int using namespace std; const int maxn = 1e6 + 10; int a[maxn]; int main() { int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } sort(a + 1, a + n); ll ans = 1ll*(a[2] + a[1]); printf("%lld\n", ans); } return 0; }
相关文章推荐
- 湖南大学ACM程序设计新生杯大赛(同步赛)G - The heap of socks
- 湖南大学ACM程序设计新生杯大赛(同步赛)E-Permutation【打表+规律】
- 湖南大学ACM程序设计新生杯大赛(同步赛) I-Piglet treasure hunt Series 1【BFS】
- 湖南大学ACM程序设计新生杯大赛(同步赛)C - Do you like Banana ?
- 湖南大学ACM程序设计新生杯大赛(同步赛) I-Piglet treasure hunt Series 1【BFS】
- 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2
- 湖南大学ACM程序设计新生杯大赛(同步赛)E - Permutation
- 湖南大学ACM程序设计新生杯大赛(同步赛)B - Build
- 湖南大学ACM程序设计新生杯大赛(同步赛)A-Array 【证明+暴力】
- 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array
- 湖南大学ACM程序设计新生杯大赛(同步赛)C-Do you like Banana ? 【几何】
- 湖南大学ACM程序设计新生杯大赛(同步赛) D -Number 【打表+暴力】
- CRT detected that the application wrote to memory after after the end of heap buffer(这个经常忘掉)
- 内存错误:CRT detected that the application wrote to memory after end of heap buffer
- 文件系统不同步问题resource is out of sync with the file system的解决办法
- codeforces D. The Union of k-Segments 排序
- UVA 11292 The Dragon of Loowater(排序问题系列)
- This may be due to a corruption of the heap
- 内存错误:CRT detected that the application wrote to memory after end of heap buffer
- uva11292 The Dragon of Loowater (排序+贪心)