2 条题解

  • 0
    @ 2024-09-01 13:13:18
    #include<stdio.h>
    #include<algorithm>
    using namespace std;
    struct stu{
        int sum, Chinese, num;
    }a[305];
    bool cmp(stu x, stu y){
        if(x.sum != y.sum)return x.sum > y.sum;
        if(x.Chinese != y.Chinese)return x.Chinese > y.Chinese;
        return x.num < y.num;
    }
    int main(){
        int n, p, q;
        scanf("%d", &n);
        for(int i = 1; i <= n; i++){
            scanf("%d%d%d", &a[i].Chinese, &p, &q);
            a[i].sum = a[i].Chinese + p + q; a[i].num = i;
        }
        sort(a+1, a+n+1, cmp);
        for(int i = 1; i <= 5; i++)printf("%d %d\n", a[i].num, a[i].sum);
        return 0;
    }
    
  • 0
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long i,ans[20000],x,y,z,n;
        cin>>n;
        for (i=1;i<=n;i++)
        {
            cin>>x>>y>>z;
            ans[i]=(x+y+z)*100000000+x*100000+99999-i;
        }
        sort(ans+1,ans+n+1);
        for (i=n;i>n-5;i--)
            cout<<99999-ans[i]%100000<<" "<<ans[i]/100000000<<endl;
        return 0;
    }
    
    
  • 1

信息

ID
1455
难度
3
分类
其他 | 排序 点击显示
标签
递交数
84
已通过
39
通过率
46%
上传者