Luo Gu small integers k-P1138

Title Description

Existing n positive integer, n≤10000 , which requires an n of positive integers k smallest integers (integer calculation only once the same size), k≤1000 , a positive integer less than 30,000 .

Input Format

The first line n and K ; second line of n values of positive integers, integers separated by spaces.

Output Format

The first k value the smallest integer; if no solution, then output "NO RESULT".

Sample input and output

Input # 1
10 3
1 3 3 7 2 5 1 2 4 6
Output # 1
3

Description / Tips

n≤10000

 

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     set<int>num;
 6     int n=0,check=0,in=0;
 7     cin>>n>>check;
 8     for(int i=0;i<n;i++){
 9         cin>>in;
10         num.insert(in); 
11     }
12     if(check>num.size()){
13         cout<<"NO RESULT";
14         return 0;
15     }
16     for(int i=0;i<check-1;i++){
17         num.erase(num.begin()); 
18     }
19     cout<<*num.begin();
20 }

 

 

 

 

Guess you like

Origin www.cnblogs.com/anbujingying/p/11293670.html