1 条题解
-
1
#include<bits/stdc++.h> using namespace std; const int N = 1e4 + 1; int n, a[N], cnt; signed main(){ cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; } for(int i = 1; i <= n; ++i){ for(int j = i; j > 1 && a[j] < a[j - 1]; --j){ swap(a[j], a[j - 1]); cnt++; } } cout << cnt; return 0; }
- 1
信息
- ID
- 116
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 2
- 标签
- 递交数
- 58
- 已通过
- 30
- 上传者