Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
102230 | 王为治 | 求逆序对数 | C++ | Accepted | 100 | 0 MS | 244 KB | 298 | 2023-09-12 13:59:56 |
#include <bits/stdc++.h> using namespace std; int a[1145]; int n; signed main() { cin >> n; for(int i = 1; i <= n; i++)cin >> a[i]; int ans = 0; for(int i = 1; i <= n; i++) { for(int j = i+1; j <= n; j++) { if(a[i]>a[j])ans++; } } cout << ans << endl; return 0; }