CODE[VS] 1739 GPA sort

Source: Internet
Author: User

Title Description Description

Nano apes and MMM are good friends. Mmm's grades are so bad that GPA (average grade point) is counted down in the grades. Grade of a total of n students, each student has their own GPA, as well as the school scores, defined Gpt=gpax has been school scores. Nano Ape in order to help MMM improve performance, to MMM made a request: the new semester GPA to exceed the rank of the first Class K students.

To help understand, here's an example:

Now give each of the students in the grade GPT (only one decimal place), and their school scores. You need to help MMM to find out the GPA of the students in the K position.

Enter a description input Description

1th Act of two integers n,k;

2nd to n+1, each row of 1 nonnegative real numbers and an integer, respectively, representing the GPT and the taken scores.

outputs description output Description

1 real numbers, representing the GPA of the class K, leaving 2 decimal places to output.

sample input to sample

5 3

73 20

79.8 21

72.6 22

85.1 23

65.7 18

Sample output Sample outputs

3.65

data size & Hint

50% of the data meet: 1≤n≤100

100% data: 1≤k≤n≤100000,gpt up to one decimal place, GPA up to 4.0

More simple questions, pay attention to the topic.

AC Code:

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <cmath>6 using namespacestd;7 8 intn,k;9 Ten structnode{ One     intA; A     Doublegpa,gpt; -}sore[100002]; -  the BOOLCMP (node X,node y) - { -     returnX.gpa >Y.gpa; - } +  - intMain () + { Ascanf"%d%d",&n,&k); at      for(intI=1; i<=n;++i) -     { -scanf"%lf%d", &sore[i].gpt,&sore[i].a); -Sore[i].gpa =sore[i].gpt*1.0/sore[i].a; -     }     -Sort (sore+1, sore+n+1, CMP); inprintf"%.2LF", Sore[k].gpa); -     return 0; to}

If you're not happy, I'll share it with the handsome fool on the right.
You see, he looks so good, and looks at you like a ZZ, are you still sad?
It's true! The picture stared at him for five seconds to laugh.
Everything's going to be over.
Time will give you answer 2333

CODE[VS] 1739 GPA sort

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.