5 条题解

  • 0
    @ 2024-11-19 17:12:12
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e4+10;
    const int INF=0x3f3f3f3f;
    struct stu
    {
    	int id;
    	int score;
    }a[N];
    	int n,m,ans;
    	
    	bool cmp(stu a1,stu a2){
    		if(a1.score==a2.score){
    			return a1.id<a2.id;
    		}
    			
    		return a1.score>a2.score;	
    	}
    
    		
    int main(){
    
    	cin>>n>>m;
    	for(int i=1;i<=n;i++){
    		cin>>a[i].id>>a[i].score;
    	}
    	sort(a+1,a+n+1,cmp);
    	m=m*1.5;
    	int tmp=a[m].score;
    	for(int j=1;j<=n;j++){
    		if(a[j].score>=tmp)
    			ans++;
    		else
    			break;
    	}
    	cout<<tmp<<" "<<ans<<endl;
    	for(int i=1;i<=ans;i++)
    		cout<<a[i].id<<" "<<a[i].score<<endl;
    	
    	return 0;
    }
    @小鸟
    
    • 0
      @ 2024-5-1 20:15:44

      #include<bits/stdc++.h> using namespace std; int n,m,ans; struct worker{ int name; int mark; }s[5005]; int cmp(worker x,worker y) { if(x.mark>y.mark)return 1; if(x.mark==y.mark && x.name<y.name)return 1; return 0; } int main() { cin>>n>>m; for(int i=1;i<=n;i++) { cin>>s[i].name>>s[i].mark; } sort(s+1,s+n+1,cmp); m=floor(m*1.5); cout<<s[m].mark<<" "; for(int i=1;i<=n;i++) { if(s[i].mark>=s[m].mark) ans++; } cout<<ans<<endl; for(int i=1;i<=n;i++) { if(s[i].mark>=s[m].mark) { cout<<s[i].name<<" "<<s[i].mark<<endl; } } return 0; }

    • 0
      #include<stdio.h>
      #include<string.h>
      #include<queue>
      #include<math.h>
      #include<vector>
      #include<algorithm>
      #include<iomanip>
      #include<stack>
      #define LL long long
      using namespace std;
      const int INF=0x3f3f3f3f;
      const int N=2e5+10;
      struct zy{
      	int id;
      	int ma;
      }a[N];
      int n,m,ans=0;
      bool cmp(zy a1,zy a2){
      	if(a1.ma==a2.ma)
      		return a1.id<a2.id;
      	return a1.ma>a2.ma;
      }
      int main(){
      	cin>>n>>m;
      	for(int i=1;i<=n;i++){
      		cin>>a[i].id>>a[i].ma;
      	}
      	sort(a+1,a+n+1,cmp);
      	m=m*1.5;
      	int tmp=a[m].ma;
      	for(int i=1;i<=n;i++){
      		if(a[i].ma>=tmp)
      			ans++;
      		else
      			break;
      	}
      	cout<<tmp<<" "<<ans<<endl;
      	for(int i=1;i<=ans;i++)
      		cout<<a[i].id<<" "<<a[i].ma<<" "<<endl;
      	return 0;
      }
      
      • 0
        @ 2024-3-17 19:00:48
        using namespace std;
        const int N=1e4+10;
        const int INF=0x3f3f3f3f;
        struct stu
        {
        	int id;
        	int score;
        }a[N];
        	int n,m,ans;
        	
        	bool cmp(stu a1,stu a2){
        		if(a1.score==a2.score){
        			return a1.id<a2.id;
        		}
        			
        		return a1.score>a2.score;	
        	}
        
        		
        int main(){
        
        	cin>>n>>m;
        	for(int i=1;i<=n;i++){
        		cin>>a[i].id>>a[i].score;
        	}
        	sort(a+1,a+n+1,cmp);
        	m=m*1.5;
        	int tmp=a[m].score;
        	for(int j=1;j<=n;j++){
        		if(a[j].score>=tmp)
        			ans++;
        		else
        			break;
        	}
        	cout<<tmp<<" "<<ans<<endl;
        	for(int i=1;i<=ans;i++)
        		cout<<a[i].id<<" "<<a[i].score<<endl;
        	
        	return 0;
        }
        
        • 0
          #include<bits/stdc++.h>
          using namespace std;
          int n,m,ans;
          	struct worker{
          		int name;
          		int mark;
          	}s[5005];
          int cmp(worker x,worker y)
          {
          	if(x.mark>y.mark)return 1;
          	if(x.mark==y.mark && x.name<y.name)return 1;
          	return 0;
          }
          int main()
          {
          	cin>>n>>m;
          	for(int i=1;i<=n;i++)
          	{
          		cin>>s[i].name>>s[i].mark;
          	}
          	sort(s+1,s+n+1,cmp);
          	m=floor(m*1.5);
          	cout<<s[m].mark<<" ";
          	for(int i=1;i<=n;i++)
          	{
          		if(s[i].mark>=s[m].mark)
          		ans++;
          	}
          	cout<<ans<<endl;
          	for(int i=1;i<=n;i++)
          	{
          		if(s[i].mark>=s[m].mark)
          		{
          		cout<<s[i].name<<" "<<s[i].mark<<endl;
          		}
          	}
          	return 0;
          }
          
          • 1

          信息

          ID
          704
          时间
          1000ms
          内存
          256MiB
          难度
          5
          标签
          递交数
          273
          已通过
          95
          上传者