結果

問題 No.397 NO MORE KADOMATSU
ユーザー 6v86v8
提出日時 2016-07-15 23:33:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 92,928 KB
実行使用メモリ 24,372 KB
平均クエリ数 36.06
最終ジャッジ日時 2023-09-24 00:17:58
合計ジャッジ時間 2,472 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,868 KB
testcase_01 AC 20 ms
23,676 KB
testcase_02 AC 20 ms
24,372 KB
testcase_03 AC 20 ms
23,508 KB
testcase_04 AC 20 ms
23,448 KB
testcase_05 AC 20 ms
24,108 KB
testcase_06 AC 20 ms
23,940 KB
testcase_07 AC 21 ms
23,580 KB
testcase_08 AC 19 ms
23,796 KB
testcase_09 AC 20 ms
23,472 KB
testcase_10 AC 21 ms
23,508 KB
testcase_11 AC 20 ms
24,168 KB
testcase_12 AC 21 ms
23,916 KB
testcase_13 AC 20 ms
23,580 KB
testcase_14 AC 22 ms
23,700 KB
testcase_15 AC 22 ms
23,664 KB
testcase_16 AC 21 ms
24,084 KB
testcase_17 AC 21 ms
24,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream> //string stream 便利!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // 可変長配列
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // 昇順sortに使う greaterが入ってる。 sortの三番目の引数。
#include <map> //map
#include<set> //set
#include<queue> //キュー
#include<list> //list
#include<cmath>
#include<cassert>
#include <numeric>
#include<tuple>
#include<iomanip>

typedef long long ll;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

using namespace std;
void omajinai() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
map<char,char> m;

int main(){
    vector<pair<int,int>> v;
    int n; cin>>n;  vector<int> a(n);
    for(int i =0 ; i<n;i++) cin>>a[i];

    for(int i = 0; i<n;i++){
        vector<int>::iterator x = max_element(a.begin()+i, a.end());
        long dif = distance(a.begin() + i,x);
        if(dif != 0){ v.push_back(make_pair(i,i+dif)); swap(*x,*(a.begin() + i));}
    }
    
    
    cout<<v.size()<<endl;
    for(pair<int,int> p: v){
        cout<<p.first<<" "<<p.second<<endl;
    }
          
    cout.flush();
    cin.ignore();
}
0