01: Who took the k-name personal blog: doubleq. win, doubleq. win
Blog: doubleq. win01: who got the k name?
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
In one test, each student's score is different. Now I know the student ID and score of each student, and I want to obtain the student ID and score of the k-th Student.
-
Input
-
The first row has two integers: the number of students n (1 ≤ n ≤ 100), and the number of students k (1 ≤ k ≤ n ).
There are n rows of data. Each row includes a student ID (integer) and a score (floating point number), separated by a space.
-
Output
-
The student ID and score for the k-th Student are output, separated by spaces. (Note: Use % g to output the score)
-
Sample Input
-
5 390788001 67.890788002 90.390788003 6190788004 68.490788005 73.9
-
Sample output
-
90788004 68.4
1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 int n,k; 6 struct s 7 { 8 int xh; 9 double cj;10 }a[1001];11 int comp(const s &a,const s &b)12 {13 return a.cj>b.cj;14 }15 int main()16 {17 cin>>n>>k;18 for(int i=1;i<=n;i++)19 {20 cin>>a[i].xh;21 cin>>a[i].cj;22 }23 sort(a+1,a+n+1,comp);24 printf("%d ",a[k].xh);25 printf("%g",a[k].cj);26 return 0;27 }