1 条题解

  • 0
    @ 2024-8-2 16:19:43

    C++ :

    #include<bits/stdc++.h>
    
    using namespace std;
    //分别代表:每个班级的金银铜牌的数量
    int r1[1010], r2[1010], r3[1010];
    int a[1010]; //每场比赛的每个班级的成绩
    int m, n;
    int main() {
        cin >> m >> n;
        for (int i = 1; i <= m; i++) {
            //第 i 场比赛,计算读入 n 个班的成绩
            //前 3 大数的下标
            int t1 = 0, t2 = 0, t3 = 0;
            for (int j = 1; j <= n; j++) {
                cin >> a[j];
                if (a[j] > a[t1]) t3 = t2, t2 = t1, t1 = j;
                else if (a[j] > a[t2]) t3 = t2, t2 = j;
                else if (a[j] > a[t3]) t3 = j;
            }
            // cout<<t1<<" "<<t2<<" "<<t3<<endl;
            r1[t1]++;
            r2[t2]++;
            r3[t3]++;
        }
        for (int i = 1; i <= n; i++) {
            cout << r1[i] << " " << r2[i] << " " << r3[i] << endl;
        }
        return 0;
    }
    
    • 1

    信息

    ID
    980
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者