提交时间:2022-07-20 11:51:02
运行 ID: 52714
#include <bits/stdc++.h> using namespace std; int a[1000005],vis[1000005]; int read(){ int x = 0,f = 0; char c = getchar(); while (c<48||c>57) f|=(!(c^'-')),c = getchar(); while (c>=48&&c<=57) x = (x<<1)+(x<<3)+(c^48),c = getchar(); return f?-x:x; } int main(){ int n,ans = 0; n = read(); for (int i=1;i<=n;i++) a[i] = read(); for (int i=1;i<=n;i++){ for (int j=i+1;j<=n;j++){ if (a[i]>a[j]&&vis[j]!=1){ ans+=j-i; vis[j] = 1; } } } printf("%d\n",ans); return 0; }