3 条题解

  • 0
    @ 2023-9-8 17:59:09

    只能说测试点太弱,竟然让我给过了

    c++

    #include<iostream>
    #include<algorithm>
    using namespace std;
    struct stu
    {
        int num;
        int c,m,e; 
        int sum;
    }student[310];
    bool cmp(stu a,stu b)
    {
        if (a.sum > b.sum) return 1;
        else if (a.sum < b.sum) return 0;
        else
        {
            if (a.c > b.c) return 1;
            else if (a.c < b.c) return 0;
            else
            {
                if (a.num > b.num) return 0;
                else return 1;
            }
        }
    }
    int main()
    {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            student[i].num = i;
            cin >> student[i].c >> student[i].m >> student[i].e;
            student[i].sum = student[i].c + student[i].m + student[i].e;
        }
        sort(student+1, student+1+n, cmp);
        for(int i = 1; i <= 5; i++)
            cout << student[i].num << ' ' << student[i].sum << endl;
        return 0;
    }
    
    • 0
      @ 2023-2-3 16:44:38
      #include <bits/stdc++.h>
      using namespace std;
      
      vector<vector<int>> g;
      
      bool cmp(vector<int> a,vector<int> b)
      {
      	if(a[1]!=b[1]) return a[1]>b[1];
      	if(a[2]!=b[2]) return a[2]>b[2];
      	return a[0]>b[0];
      }
      
      int main()
      {
      	int n;
      	cin >> n;
      	for(int i=1;i<=n;i++)
      	{
      		vector<int> t;
      		t.push_back(i);
      		int a,b,c;
      		cin >> a >> b >> c;
      		t.push_back(a+b+c);
      		t.push_back(a);
      		t.push_back(b);
      		t.push_back(c);
      		g.push_back(t);
      	}
      	sort(g.begin(),g.end(),cmp);
      	if(g.size()>=5)
      	{
      		for(int i=0;i<5;i++)
      			cout << g[i][0] << " " << g[i][1] << endl;
      	}
      	else for(int i=0;i<g.size();i++)
      		cout << g[i][0] << " " << g[i][1] << endl;
      	return 0;
      }
      
      • -4
        @ 2023-7-31 16:53:09

        朴实无华

        #include<bits/stdc++.h>
        
        using namespace std;
        
        int a[10000];
        int l[10000];
        int b[10000];
        int sc[10000];
        
        int main()
        {
        
            int n;
            cin >>n;
            for(int i=1; i<=n*3; i++){
                cin >>sc[i];
            }
            for(int i=1; i<=n; i++){
                a[i]=sc[i*3-2];
                l[i]=sc[i*3-2]+sc[i*3-1]+sc[i*3];
                b[i]=i;
            }
            for(int i=1; i<=n; i++){
                for(int j=1; j<=n; j++){
                    if(l[j]<l[j+1]){
                        swap(l[j],l[j+1]);
                        swap(b[j],b[j+1]);
                        swap(a[j],a[j+1]);
                    }
                    if(l[j]==l[j+1] && a[j]<a[j+1]){
                        swap(l[j],l[j+1]);
                        swap(a[j],a[j+1]);
                        swap(b[j],b[j+1]);
                    }
                    if(l[j]==l[j+1] && a[j]==a[j+1] && b[j]>b[j+1]){
                        swap(l[j],l[j+1]);
                        swap(b[j],b[j+1]);
                        swap(a[j],a[j+1]);
                    }
                }
            }
        
            for(int i=1; i<6; i++){
                cout<<b[i]<<" "<<l[i]<<endl;
            }
        
        	return 0;
        }
        
        • 1

        信息

        ID
        797
        时间
        1000ms
        内存
        256MiB
        难度
        7
        标签
        (无)
        递交数
        480
        已通过
        118
        上传者