結果

問題 No.397 NO MORE KADOMATSU
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-18 03:04:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 3,646 ms
コンパイル使用メモリ 75,876 KB
実行使用メモリ 75,484 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 01:48:56
合計ジャッジ時間 9,279 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
73,300 KB
testcase_01 AC 174 ms
73,004 KB
testcase_02 AC 147 ms
72,608 KB
testcase_03 AC 206 ms
72,292 KB
testcase_04 AC 184 ms
72,728 KB
testcase_05 AC 209 ms
71,064 KB
testcase_06 AC 256 ms
71,276 KB
testcase_07 AC 266 ms
72,664 KB
testcase_08 AC 205 ms
72,764 KB
testcase_09 AC 157 ms
70,208 KB
testcase_10 AC 416 ms
75,484 KB
testcase_11 AC 155 ms
70,256 KB
testcase_12 AC 286 ms
73,412 KB
testcase_13 AC 316 ms
72,792 KB
testcase_14 AC 319 ms
73,456 KB
testcase_15 AC 314 ms
73,044 KB
testcase_16 AC 147 ms
71,996 KB
testcase_17 AC 147 ms
71,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No397{
	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();
		}
		int M = 0;
		int[][] uv = new int[N*N][2];
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N - 1 - i; j++){
				if(A[j] > A[j+1]){
					int tmp = A[j];
					A[j] = A[j+1];
					A[j+1] = tmp;
					uv[M][0] = j;
					uv[M][1] = j+1;
					M++;
				}
			}
		}
		System.out.println(M);
		for(int i = 0; i < M; i++){
			System.out.println(uv[i][0] + " " + uv[i][1]);
		}
		int a = sc.nextInt();

	}
}
0