結果

問題 No.397 NO MORE KADOMATSU
ユーザー FF256grhyFF256grhy
提出日時 2016-07-15 22:56:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 26,104 KB
実行使用メモリ 24,336 KB
平均クエリ数 52.44
最終ジャッジ日時 2023-09-24 00:15:21
合計ジャッジ時間 1,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int n, a[100], b[100], c[100], d;

int main() {
	scanf("%d\n", &n);
	for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
	
	
	for(int i =     0; i <  n; i++) { int p = n - 1;
	for(int j = n - 1; j >= i; j--) {
		if(a[j] < a[p]) { p = j; }
	} if(p != i) { b[d] = i; c[d] = p; d++; } int temp = a[i]; a[i] = a[p]; a[p] = temp;
	}
	
	printf("%d\n", d);
	for(int i = 0; i < d; i++){ printf("%d %d\n", b[i], c[i]); }
	fflush(stdout);
	
	
	return 0;
}
0