結果

問題 No.397 NO MORE KADOMATSU
ユーザー yosupotyosupot
提出日時 2016-07-15 22:39:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 101,500 KB
実行使用メモリ 24,348 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:13:15
合計ジャッジ時間 2,548 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,580 KB
testcase_01 AC 23 ms
24,036 KB
testcase_02 AC 24 ms
24,048 KB
testcase_03 AC 26 ms
23,796 KB
testcase_04 AC 24 ms
23,916 KB
testcase_05 AC 26 ms
24,348 KB
testcase_06 AC 27 ms
23,676 KB
testcase_07 AC 29 ms
23,400 KB
testcase_08 AC 25 ms
23,400 KB
testcase_09 AC 25 ms
23,676 KB
testcase_10 AC 53 ms
23,580 KB
testcase_11 AC 24 ms
23,352 KB
testcase_12 AC 32 ms
23,364 KB
testcase_13 AC 36 ms
23,352 KB
testcase_14 AC 36 ms
23,520 KB
testcase_15 AC 37 ms
24,252 KB
testcase_16 AC 24 ms
23,412 KB
testcase_17 AC 24 ms
23,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    using P = pair<int, int>;
    vector<P> res;
    for (int i = 0; i < n; i++) {
        for (int j = n-1; j-1 >= i; j--) {
            if (a[j-1] > a[j]) {
                res.push_back(P(j-1, j));
                swap(a[j-1], a[j]);
            }
        }
    }
    cout << res.size() << endl;
    for (P p: res) {
        cout << p.first << " " << p.second << endl;
    }
    int d;
    cin >> d;
    return 0;
}
0