結果

問題 No.397 NO MORE KADOMATSU
ユーザー NagisaNagisa
提出日時 2016-07-19 07:40:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 169,068 KB
実行使用メモリ 24,372 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:22:47
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,156 KB
testcase_01 AC 24 ms
23,412 KB
testcase_02 AC 24 ms
24,312 KB
testcase_03 AC 25 ms
24,348 KB
testcase_04 AC 24 ms
24,036 KB
testcase_05 AC 26 ms
24,336 KB
testcase_06 AC 28 ms
24,168 KB
testcase_07 AC 31 ms
24,312 KB
testcase_08 AC 25 ms
23,652 KB
testcase_09 AC 25 ms
24,360 KB
testcase_10 AC 53 ms
23,364 KB
testcase_11 AC 24 ms
24,024 KB
testcase_12 AC 33 ms
24,372 KB
testcase_13 AC 35 ms
23,628 KB
testcase_14 AC 39 ms
23,364 KB
testcase_15 AC 37 ms
23,352 KB
testcase_16 AC 24 ms
24,348 KB
testcase_17 AC 25 ms
24,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A;
    int t;
    REP(i,N){
        cin >> t;
        A.push_back(t);
    }

    int i = 0;
    int c = 0;
    vector<pair<int,int> > ans;
    while(i<N-1){
        if(A[i]>A[i+1]){
            ans.push_back(make_pair(i,i+1));
            t = A[i];
            A[i] = A[i+1];
            A[i+1] = t;
            i = 0;
            c++;
        }else{
            i++;
        }
    }
    cout << c << endl;
    for(pair<int,int> p : ans){
        cout << p.first << " " << p.second << endl;
    }
    int D;
    cin >> D;
    return 0;
}
0