05: Score Line, and 05 Score Line

Source: Internet
Author: User

05: Score Line, and 05 Score Line
05: Score Line demarcation

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

The selection of volunteers for the Expo is in full swing in City. In order to select the most suitable talent, City A has performed A written examination on all contestants who have registered. Only contestants whose scores have reached the interview score can enter the interview. The interview score is based on 150% of the number of students enrolled. That is, if you plan to enroll m volunteers, the interview score is the score of the contestant ranking m * 150% (rounded down, the final contestants who enter the interview are all contestants whose written examination scores are no less than the Interview Score.

Now, please write a program to define the interview scores, and output the registration numbers and test scores of all contestants entering the interview.

Input
The first line contains two integers, n and m (5 ≤ n ≤, 3 ≤ m ≤ n), separated by a space. n indicates the total number of contestants who have registered for the test, m indicates the number of volunteers to be admitted. Input data must be m * 150% rounded down and less than or equal to n.
Line 2 to line n + 1, each line contains two integers separated by a space, respectively, the contestant's registration number k (1000 ≤ k ≤ 9999) and the contestant's test score s (1 ≤ s ≤ 100 ). Data ensures that contestants have different registration numbers.
Output
The first line has two integers separated by a space. The first integer represents the Interview Score Line. The second integer represents the actual number of contestants who enter the interview.
Starting from the second line, each line contains two integers separated by a space in the middle, indicating the contestant's registration number and written test score, respectively, according to the written test score from high to low, if the score is the same, it is output in the order of the registration number from small to large.
Sample Input
6 31000 903239 882390 957231 841005 951001 88
Sample output
88 51005 952390 951000 901001 883239 88
Prompt
Example: m * 150% = 3 * 150% = 4.5, rounded down to 4. Ensure that the score of four people for the interview is 88, but because there are 88 scores, all contestants with scores greater than or equal to 88 can enter the interview, so five people finally enter the interview.
Source
Topic 2 of NOIP2009 semi-finals popularity Group,
 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 #include<cmath> 6 using namespace std; 7 int n,m; 8 struct s 9 {10     int xh;11     int cj;12 }a[10001];13 int comp(const s &a,const s &b)14 {15     if(a.cj>b.cj)return 1;16     if(a.cj<b.cj)return 0;17     if(a.xh<b.xh)return 1;18     if(a.xh>b.xh)return 0;19 }20 int main()21 {22     cin>>n>>m;23     for(int i=1;i<=n;i++)24     {25         cin>>a[i].xh;26         cin>>a[i].cj;27     }28     sort(a+1,a+n+1,comp);29     /*printf("%s",a[k].xh);30     printf("%d",a[k].cj);*/31     int p=(double)(floor)(m*1.5);32     int now=1;33     while(1)34     {35         if(a[p].cj==a[p+now].cj&&(p+now<=n))36         {37             now++;38         }39         else 40         break;41     }42     cout<<a[p].cj<<" "<<p+now-1<<endl;43     for(int i=1;i<=p+now-1;i++)44     {45         cout<<a[i].xh<<" ";46         cout<<a[i].cj<<endl;47     }48     return 0;49 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.