結果

問題 No.397 NO MORE KADOMATSU
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 19:51:43
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 822 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 77,136 KB
実行使用メモリ 75,584 KB
平均クエリ数 188.61
最終ジャッジ日時 2023-09-23 11:23:00
合計ジャッジ時間 8,504 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
72,732 KB
testcase_01 AC 171 ms
73,208 KB
testcase_02 AC 144 ms
71,476 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 158 ms
72,216 KB
testcase_10 RE -
testcase_11 AC 154 ms
71,980 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 148 ms
71,952 KB
testcase_17 AC 147 ms
71,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
		static int INF = 2 << 27;
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int[] A = new int[N];
			for(int i = 0; i < N; i++) {
				A[i] = sc.nextInt();
			}
			List<Integer> u = new ArrayList<>();
			List<Integer> v = new ArrayList<>();
			for(int i = 1; i < N; i++) {
				for(int j = i-1; j >= 0; j--) {
					if(A[j] <= A[i] || j == 0) {
						if(j+1 == i) break;
						int tmp = A[j+1];
						A[j+1] = A[i];
						A[i] = tmp;
						u.add(j+1);
						v.add(i);
					}
				}
			}
			System.out.println(u.size());
			for(int i = 0; i < u.size(); i++) {
				System.out.println(u.get(i) + " " + v.get(i));
			}
			System.out.flush();
			sc.nextInt();
		}

		

}
0