結果

問題 No.397 NO MORE KADOMATSU
ユーザー TatsuDXTatsuDX
提出日時 2016-09-09 00:48:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 3,415 ms
コンパイル使用メモリ 75,620 KB
実行使用メモリ 73,576 KB
平均クエリ数 36.06
最終ジャッジ日時 2023-09-24 00:31:40
合計ジャッジ時間 7,992 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
72,956 KB
testcase_01 AC 169 ms
71,104 KB
testcase_02 AC 164 ms
72,844 KB
testcase_03 AC 187 ms
72,908 KB
testcase_04 AC 182 ms
73,140 KB
testcase_05 AC 187 ms
72,636 KB
testcase_06 AC 180 ms
72,980 KB
testcase_07 AC 179 ms
72,956 KB
testcase_08 AC 172 ms
72,892 KB
testcase_09 AC 148 ms
70,496 KB
testcase_10 AC 153 ms
71,424 KB
testcase_11 AC 152 ms
71,716 KB
testcase_12 AC 189 ms
72,876 KB
testcase_13 AC 190 ms
72,492 KB
testcase_14 AC 191 ms
73,576 KB
testcase_15 AC 191 ms
72,660 KB
testcase_16 AC 164 ms
72,680 KB
testcase_17 AC 167 ms
72,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), max, idx = 0, tmp;
		int[] m = new int[n];
		int[][] ans = new int[n][2];
		for (int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			max = i;
			for (int j = i + 1; j < n; j++) {
				if (m[max] < m[j]) {
					max = j;
				}
			}
			if (i != max) {
				ans[idx][0] = i;
				ans[idx][1] = max;
				idx++;
				tmp = m[i];
				m[i] = m[max];
				m[max] = tmp;
			}
		}
		System.out.println(idx);
		for (int i = 0; i < idx; i++) {
			System.out.println(ans[i][0] + " " + ans[i][1]);
		}
		int p = sc.nextInt();
	}
}
0