Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
128016 maoyu 车厢重组 C++ Accepted 100 893 MS 440 KB 314 2024-01-25 11:24:05

Tests(12/12):


#include<bits/stdc++.h> using namespace std; int main() { int n,cnt = 0; cin >> n; int a[n+1]; for (int i = 0;i < n;i++) cin >> a[i]; for (int i = n;i > 1;i--){ for (int j = 0;j < i - 1;j++){ if (a[j] > a[j+1]){ swap(a[j],a[j+1]); cnt++; } } } cout << cnt; return 0; }


Judgement Protocol: