結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-09-09 00:48:08 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 189 ms / 2,000 ms |
コード長 | 703 bytes |
コンパイル時間 | 4,021 ms |
コンパイル使用メモリ | 79,868 KB |
実行使用メモリ | 73,348 KB |
平均クエリ数 | 36.06 |
最終ジャッジ日時 | 2024-07-17 00:24:45 |
合計ジャッジ時間 | 7,513 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
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(); } }