Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
135999 林泽豪 学生排队 C++ Wrong Answer 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; }


Judgement Protocol: