結果

問題 No.397 NO MORE KADOMATSU
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-16 00:08:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 201,088 KB
実行使用メモリ 24,360 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 02:19:13
合計ジャッジ時間 3,746 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,640 KB
testcase_01 AC 21 ms
24,000 KB
testcase_02 AC 21 ms
24,360 KB
testcase_03 AC 23 ms
23,988 KB
testcase_04 AC 21 ms
24,000 KB
testcase_05 AC 22 ms
23,772 KB
testcase_06 AC 23 ms
23,796 KB
testcase_07 AC 24 ms
23,808 KB
testcase_08 AC 22 ms
23,628 KB
testcase_09 AC 22 ms
24,360 KB
testcase_10 AC 45 ms
24,240 KB
testcase_11 AC 21 ms
23,508 KB
testcase_12 AC 28 ms
24,156 KB
testcase_13 AC 36 ms
23,376 KB
testcase_14 AC 33 ms
24,348 KB
testcase_15 AC 34 ms
24,324 KB
testcase_16 AC 21 ms
23,400 KB
testcase_17 AC 20 ms
23,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    vector<int> b;
    for (int i=0;i<n;i++)
        for (int j=n-1;j>i;j--)
            if (a[j-1]>a[j]) {
                b.push_back(j-1);
                swap(a[j-1],a[j]);
            }
    cout<<b.size()<<endl;
    for (int x:b) cout<<x<<' '<<x+1<<endl;
    int d;cin>>d;
    return 0;
}
0