地址:http://codeforces.com/contest/263/problem/B
给出n个正方形的顶点(与(0,0)在同一对角线上),要求找到一个点包含在k个正方形内
n<k则无法找到
n>=k时,读入数据后排序
输出从右数第k个顶点的坐标即可
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n,k,a[55]; 6 7 bool cmp(int a,int b) 8 {return a<b;} 9 10 int main() 11 { 12 int i; 13 cin>>n>>k; 14 if(k>n) cout<<"-1"<<endl; 15 else 16 { 17 for(i=0;i<n;i++) 18 { 19 cin>>a[i]; 20 } 21 sort(a,a+n,cmp); 22 cout<<a[n-k]<<" "<<a[n-k]<<endl; 23 } 24 return 0; 25 }
来源:https://www.cnblogs.com/tjsuhst/archive/2013/01/23/2873622.html