結果

問題 No.397 NO MORE KADOMATSU
ユーザー Nagisa
提出日時 2016-07-19 07:40:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 173,380 KB
実行使用メモリ 25,476 KB
平均クエリ数 936.56
最終ジャッジ日時 2024-07-17 00:14:01
合計ジャッジ時間 3,487 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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