Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
135999 林泽豪 学生排队 C++ 解答错误 0 69 MS 312 KB 518 2024-03-07 13:52:07

Tests(0/10):


#include<bits/stdc++.h> using namespace std; int n; struct student{ int unhappy; int high; }student[10000]; int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>student[i].high; for(int i=1;i<n;i++){ for(int j=i+1;j<=n;j++){ if(student[i].high >student[j].high ){ student[i].unhappy++; student[j].unhappy++; swap(student[i],student[j]); } } } int sum=0; for(int i=1;i<=n;i++){ for(int j=1;j<=student[j].unhappy;j++ )sum+=j; } cout<<sum; }


测评信息: