結果

問題 No.397 NO MORE KADOMATSU
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-07-15 22:50:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 168,524 KB
実行使用メモリ 24,396 KB
平均クエリ数 36.06
最終ジャッジ日時 2023-09-24 00:14:53
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,616 KB
testcase_01 AC 24 ms
23,568 KB
testcase_02 AC 24 ms
23,352 KB
testcase_03 AC 24 ms
24,024 KB
testcase_04 AC 24 ms
23,616 KB
testcase_05 AC 24 ms
24,012 KB
testcase_06 AC 25 ms
24,396 KB
testcase_07 AC 24 ms
23,820 KB
testcase_08 AC 24 ms
23,664 KB
testcase_09 AC 23 ms
23,616 KB
testcase_10 AC 23 ms
23,820 KB
testcase_11 AC 24 ms
23,352 KB
testcase_12 AC 25 ms
23,628 KB
testcase_13 AC 24 ms
23,220 KB
testcase_14 AC 24 ms
23,352 KB
testcase_15 AC 24 ms
24,024 KB
testcase_16 AC 24 ms
24,036 KB
testcase_17 AC 23 ms
24,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

int N;
int A[100];
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	vector<pair<int, int> > ans;
	rep(i, 0, N) {
		int _max = i;
		rep(j, i + 1, N) if (A[_max] < A[j]) _max = j;
		if (_max != i) {
			ans.push_back(make_pair(i, _max));
			swap(A[i], A[_max]);
		}
	}

	cout << ans.size() << endl;
	for (auto p : ans) printf("%d %d\n", p.first, p.second);

	int d; cin >> d;
}
0