当前位置:网站首页>1176 questions of Olympiad in informatics -- who ranked K in the exam
1176 questions of Olympiad in informatics -- who ranked K in the exam
2022-07-27 08:13:00 【Bamboo monk-】
Define collation 【 Title Description 】
In an exam , Every student's grades are different , Now I know the student number and grade of each student , Ask for the first place k Student number and grade of students .
【 Input 】
The first line has two integers , The number of students n(1≤n≤100), He Qiudi k Students k(1≤k≤n).
After that n Row data , Each line includes a student number ( Integers ) And an achievement ( Floating point numbers ), Separated by a space .
【 Output 】
Output No k Student number and grade of students , Space between .( notes : Please use %g Output results )
【 sample input 】
5 3 90788001 67.8 90788002 90.3 90788003 61 90788004 68.4 90788005 73.9
【 sample output 】
90788004 68.4
Ideas :
1. Because the student number is related to the grade , You need to use structures to store
2. We need to find the number k Scores of students , We must first make the results orderly
3. The sorting rule is from big to small
4. Directly output the second k First grade
5. Mentioned in the question %g Output results , So we need to use printf
Code :
Defining structure
#include<bits/stdc++.h>
using namespace std;
const int N=110;
struct node
{
int id;
double score;
}a[N];Define collation
bool cmp(node x,node y)
{
return x.score>y.score;
}The main program
int n,k;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i].id>>a[i].score;
}
sort(a+1,a+n+1,cmp);
printf("%d",a[k].id);
cout<<" ";
printf("%g",a[k].score);
return 0;
}边栏推荐
- "PHP Basics" uses echo statements to output information
- Leetcode54. Spiral matrix
- My senior
- Demo:st05 find text ID information
- How to play with the purchase of SAP variant materials? Look at this article and you will understand
- 一文速览EMNLP 2020中的Transformer量化论文
- C commissioned use cases
- opengauss从库停掉,发现主库无法写入数据
- 物联网工业级UART串口转WiFi转有线网口转以太网网关WiFi模块选型
- 二零二零年终总结
猜你喜欢
![[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement](/img/28/979dceac1454a3e53409a4feb20320.png)
[day42 literature intensive reading] a Bayesian model of perfect head centered velocity during smooth pursuit eye movement

Digital transformation driven by enterprise architecture!

Use of string type "PHP Basics"

The dragon lizard exhibition area plays a new trick this time. Let's see whose DNA moved?

2020 International Machine Translation Competition: Volcano translation won five championships

Record a PG master-slave setup and data synchronization performance test process

pytorch_ demo1

idea远程调试

"PHP Basics" PHP statements and statement blocks

Abstract factory pattern
随机推荐
What is a rebound shell? What's the use of bouncing shells?
Vcenter7.0 installation of ibm3650m4 physical machine
containerd拉取私库镜像失败(kubelet)
The third letter to the little sister of the test | Oracle stored procedure knowledge sharing and test instructions
Lua有状态迭代器
Grandson's questions are difficult, and his son's invigilation is strict. I can't do it. Pay back my school money
数据库启动报error_user_connect_times &gt; 0错误
"PHP Basics" uses echo statements to output information
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
1024 | in the fourth year officially called Menon, the original intention is still there, and continue to move forward
Methods of server network testing
这次龙蜥展区玩的新花样,看看是谁的 DNA 动了?
ERP生产作业控制 华夏
PHP realizes data interaction with MySQL
QingChuang technology joined dragon lizard community to build a new ecosystem of intelligent operation and maintenance platform
Enhancement: BTE process introduction
[applet] how to get wechat applet code upload key?
What is the real HTAP? (1) Background article
Abstract factory pattern
虚拟机克隆