結果

問題 No.397 NO MORE KADOMATSU
ユーザー nCk_cvnCk_cv
提出日時 2016-08-28 20:45:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 78,788 KB
実行使用メモリ 76,112 KB
平均クエリ数 2019.33
最終ジャッジ日時 2023-09-24 00:28:58
合計ジャッジ時間 7,594 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
72,912 KB
testcase_01 AC 152 ms
72,644 KB
testcase_02 AC 126 ms
71,944 KB
testcase_03 AC 260 ms
73,668 KB
testcase_04 AC 177 ms
73,124 KB
testcase_05 AC 242 ms
72,884 KB
testcase_06 AC 245 ms
73,300 KB
testcase_07 AC 250 ms
73,072 KB
testcase_08 AC 164 ms
72,604 KB
testcase_09 AC 377 ms
76,112 KB
testcase_10 AC 383 ms
75,784 KB
testcase_11 AC 377 ms
74,984 KB
testcase_12 AC 387 ms
73,096 KB
testcase_13 AC 321 ms
75,784 KB
testcase_14 AC 327 ms
75,700 KB
testcase_15 AC 329 ms
75,268 KB
testcase_16 AC 125 ms
71,568 KB
testcase_17 AC 151 ms
72,720 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 = 0; i < N; i++) {
				for(int j = i-1; j  >= 0; j--) {
					if(A[j] >= A[j+1]) {
						int tmp = A[j];
						A[j] = A[j+1];
						A[j+1] = tmp;
						u.add(j);
						v.add(j+1);
					}
				}
			}
			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