結果

問題 No.397 NO MORE KADOMATSU
ユーザー dnishdnish
提出日時 2017-07-10 21:32:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 1,366 ms
コンパイル使用メモリ 169,036 KB
実行使用メモリ 24,300 KB
平均クエリ数 36.06
最終ジャッジ日時 2023-09-24 01:23:21
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,460 KB
testcase_01 AC 20 ms
23,928 KB
testcase_02 AC 23 ms
24,120 KB
testcase_03 AC 22 ms
23,916 KB
testcase_04 AC 20 ms
24,300 KB
testcase_05 AC 20 ms
23,544 KB
testcase_06 AC 21 ms
23,232 KB
testcase_07 AC 20 ms
23,316 KB
testcase_08 AC 19 ms
23,304 KB
testcase_09 AC 21 ms
24,024 KB
testcase_10 AC 19 ms
23,844 KB
testcase_11 AC 20 ms
23,964 KB
testcase_12 AC 20 ms
23,916 KB
testcase_13 AC 24 ms
23,388 KB
testcase_14 AC 20 ms
23,328 KB
testcase_15 AC 21 ms
24,132 KB
testcase_16 AC 20 ms
23,544 KB
testcase_17 AC 20 ms
24,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
#define F first
#define S second
using namespace std;


int main() {
	int n;
	cin>>n;
	int A[110];
	vector<pair<int,int>> ans;
	REP(i,0,n) cin>>A[i];
	REP(i,0,n){
		int mx=i;
		REP(j,i+1,n) if(A[mx]<A[j]) mx=j;
		if(mx!=i){
			ans.push_back({i,mx});
			swap(A[i],A[mx]);
		}
	}
	p(ans.size());
	for(auto p:ans) cout<<p.F<<" "<<p.S<<endl;
	cin>>n;
	return 0;
}
0