1 solutions

  • 3
    @ 2024-8-22 14:55:29
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1001;
    struct Student
    {
    	int name;
    	double sc;
    }s[N];
    bool cmp(Student a,Student b)
    {
    	if(a.sc>b.sc) return 1;
    	if(a.sc==b.sc&&a.name<b.name) return 1;
    	return 0;
    }
    int main()
    {
    	int n,m;
    	cin>>n>>m;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>s[i].name>>s[i].sc;
    	}
    	sort(s+1,s+n+1,cmp);
    	cout<<s[m].name<<" "<<s[m].sc;
    }
    
    • 1

    Information

    ID
    944
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    61
    Accepted
    21
    Uploaded By