6 条题解

  • 1
    @ 2024-08-23 14:59:58
    #include<bits/stdc++.h>
    using namespace std;
    struct stu{
        int num, a[5], total;
        string name;
    }s[1010];
    bool cmp(stu x, stu y){
        if(x.total != y.total)return x.total > y.total;
        else return x.a[0] > y.a[0];
    }
    int main(){
        ios::sync_with_stdio(false);
        int q, cnt = 0;
        cin >> q;
        for(int i = 1; i <= q; i++){
            cin >> s[i].num >> s[i].name;
            for(int j = 0; j <= 4; j++)cin >> s[i].a[j];
            s[i].total = s[i].a[0]+s[i].a[1]+s[i].a[2]+s[i].a[3]+s[i].a[4];
            if(s[i].a[0]<60 || s[i].a[1]<60 || s[i].a[2]<60 || s[i].a[3]<60 || s[i].a[4]<60)cnt++;
        }
        sort(s+1, s+q+1, cmp);
        q = min(q, 20);
        cout << cnt << endl;
        for(int i = 1; i <= q; i++){
            cout << s[i].num << ' ' << s[i].name << ' ';
            for(int j = 0; j <= 4; j++)cout << s[i].a[j] << ' ';
            cout << s[i].total << endl;
        }
        return 0;
    }
    
  • 1

    #include<bits/stdc++.h>
    using namespace std;
    struct student{
    long long ID;
    string name;
    int Chinese,Maths,English,Physics,Chemistry;
    int total_score;
    }a[1005];
    bool compare(student x,student y)
    {
    if(x.total_score!=y.total_score)return x.total_score>y.total_score;
    return x.Chinese>y.Chinese;
    }
    int main()
    {
    int n,fail=0;cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>a[i].ID>>a[i].name>>a[i].Chinese>>a[i].Maths>>a[i].English>>a[i].Physics>>a[i].Chemistry;
    a[i].total_score=a[i].Chinese+a[i].Maths+a[i].English+a[i].Physics+a[i].Chemistry;
    if(a[i].Chinese<60||a[i].Maths<60||a[i].English<60||a[i].Physics<60||a[i].Chemistry<60)fail++;
    }
    sort(a+1,a+n+1,compare);
    cout<<fail<<endl;
    for(int i=1;i<=min(n,20);i++)
    {
    cout<<a[i].ID<<' '<<a[i].name<<' '<<a[i].Chinese<<' '<<a[i].Maths<<' '<<a[i].English<<' '<<a[i].Physics<<' '<<a[i].Chemistry<<' '<<a[i].total_score<<endl;
    }
    return 0;
    }

  • 1

    #include<bits/stdc++.h>
    using namespace std;
    struct student{
    long long ID;
    string name;
    int Chinese,Maths,English,Physics,Chemistry;
    int total_score;
    }a[1005];
    bool compare(student x,student y)
    {
    if(x.total_score!=y.total_score)return x.total_score>y.total_score;
    return x.Chinese>y.Chinese;
    }
    int main()
    {
    int n,fail=0;cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>a[i].ID>>a[i].name>>a[i].Chinese>>a[i].Maths>>a[i].English>>a[i].Physics>>a[i].Chemistry;
    a[i].total_score=a[i].Chinese+a[i].Maths+a[i].English+a[i].Physics+a[i].Chemistry;
    if(a[i].Chinese<60||a[i].Maths<60||a[i].English<60||a[i].Physics<60||a[i].Chemistry<60)fail++;
    }
    sort(a+1,a+n+1,compare);
    cout<<fail<<endl;
    for(int i=1;i<=min(n,20);i++)
    {
    cout<<a[i].ID<<' '<<a[i].name<<' '<<a[i].Chinese<<' '<<a[i].Maths<<' '<<a[i].English<<' '<<a[i].Physics<<' '<<a[i].Chemistry<<' '<<a[i].total_score<<endl;
    }
    return 0;
    }

  • 0
    @ 2024-08-23 15:00:42
    #include<iostream>
    #include<string>
    using namespace std;
    int a[1002];
    struct stu{
        int num, a1, a2, a3, a4, a5, sum;
        string name;
    }s[1002];
    int main(){
        ios::sync_with_stdio(false);
        int n, ans = 0;
        cin >> n;
        for(int i = 1; i <= n; i++){
            cin >> s[i].num >> s[i].name >> s[i].a1 >> s[i].a2 >> s[i].a3 >> s[i].a4 >> s[i].a5;
            if(s[i].a1 < 60 || s[i].a2 < 60 || s[i].a3 < 60 || s[i].a4 < 60 || s[i].a5 < 60)ans++;
            s[i].sum = s[i].a1 + s[i].a2 + s[i].a3 + s[i].a4 + s[i].a5;
        }
        for(int i = 1; i <= n; i++)a[i] = i;
        for(int i = n; i >= 1; i--){
            for(int j = 1; j < i; j++)if(s[j].sum < s[j+1].sum)swap(a[j], a[j+1]);
        }
        if(n > 20)n = 20;
        cout << ans << endl;
        for(int i = 1; i <= n; i++)cout << s[a[i]].num << " " << s[a[i]].name << " " << s[a[i]].a1 << " " << s[a[i]].a2 << " " << s[a[i]].a3 << " " << s[a[i]].a4 << " " << s[a[i]].a5 << " " << s[a[i]].sum << endl; 
        return 0;
    }
    
  • -1
    #include<bits/stdc++.h>
    using namespace std;
    int n,bjg;
    struct cj
    {
        double yw,sx,yy,wl,hx,zf,xh;
        string stu;
        bool operator<(cj x)const
        {
            return zf>x.zf||zf==x.zf&&yw>x.yw;
        }
    };
    vector<cj>a;
    int main()
    {
        cin>>n;a.resize(n);
        for(int i=0;i<n;i++)
        {
            cin>>a[i].xh>>a[i].stu>>a[i].yw>>a[i].sx>>a[i].yy>>a[i].wl>>a[i].hx;
            a[i].zf=a[i].yw+a[i].sx+a[i].yy+a[i].wl+a[i].hx;
            if(!(a[i].yw<60||a[i].sx<60||a[i].yy<60||a[i].wl<60||a[i].hx<60))continue;
            bjg++;
        }
        sort(a.begin(),a.end());
        cout<<bjg<<endl;
        if(n>=20)n=20;
        for(int i=0;i<n;i++)
            cout<<a[i].xh<<' '<<a[i].stu<<' '<<a[i].yw<<' '<<a[i].sx<<' '<<a[i].yy<<' '<<a[i].wl<<' '<<a[i].hx<<' '<<a[i].zf<<endl;
        cout<<"代码仅供参考"<<endl;
        cout<<"抄题解的死全家"<<endl; 
        return 0;
    }
    
    
  • -5
    @ 2022-08-21 16:10:34
    //我是小牛逼,越来越牛逼!
    
  • 1

信息

ID
1005
难度
6
分类
(无)
标签
递交数
178
已通过
48
通过率
27%
被复制
9
上传者