結果

問題 No.397 NO MORE KADOMATSU
ユーザー hotpepsihotpepsi
提出日時 2016-07-29 00:48:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 60,984 KB
実行使用メモリ 24,300 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 00:23:43
合計ジャッジ時間 2,054 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,988 KB
testcase_01 AC 19 ms
24,300 KB
testcase_02 AC 20 ms
24,084 KB
testcase_03 AC 20 ms
23,592 KB
testcase_04 AC 19 ms
23,604 KB
testcase_05 AC 21 ms
23,616 KB
testcase_06 AC 21 ms
23,328 KB
testcase_07 AC 24 ms
23,880 KB
testcase_08 AC 24 ms
24,060 KB
testcase_09 AC 23 ms
23,880 KB
testcase_10 AC 63 ms
23,472 KB
testcase_11 AC 20 ms
24,084 KB
testcase_12 AC 20 ms
24,096 KB
testcase_13 AC 39 ms
24,000 KB
testcase_14 AC 42 ms
23,328 KB
testcase_15 AC 42 ms
23,868 KB
testcase_16 AC 20 ms
23,328 KB
testcase_17 AC 20 ms
23,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	int A[100];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<pair<int, int> > v;
	int i = 0, j;
	while (i < N) {
		for (i = 0; i < N; ++i) {
			for (j = i + 1; j < N; ++j) {
				if (A[i] > A[j]) {
					break;
				}
			}
			if (j < N) {
				v.push_back(make_pair(i, j));
				swap(A[i], A[j]);
				break;
			}
		}
	}
	cout << v.size() << endl;
	for (i = 0; i != v.size(); ++i) {
		cout << v[i].first << " " << v[i].second << endl;
	}
	cin >> N;
	return 0;
}
0