結果
問題 | No.1604 Swap Sort:ONE |
ユーザー |
|
提出日時 | 2021-07-16 21:25:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 362 bytes |
コンパイル時間 | 499 ms |
コンパイル使用メモリ | 66,416 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 08:16:05 |
合計ジャッジ時間 | 1,660 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <iostream>#include <algorithm>using namespace std;int p[3009];int main(){ios::sync_with_stdio(false);cin.tie(0);int n; cin >> n;for (int i = 1; i <= n; i++) {int a; cin >> a;p[a] = i;}int ans = 0;for (int i = 1; i <= n; i++)for (int j = i + 1; j <= n; j++)if (p[i] > p[j])ans++;cout << ans << '\n';return 0;}