結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
72,836 KB
testcase_01 AC 176 ms
73,140 KB
testcase_02 AC 148 ms
71,940 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 154 ms
71,804 KB
testcase_10 RE -
testcase_11 AC 158 ms
72,172 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 149 ms
71,556 KB
testcase_17 AC 146 ms
72,192 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