結果

問題 No.397 NO MORE KADOMATSU
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-18 02:57:26
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 627 bytes
コンパイル時間 3,633 ms
コンパイル使用メモリ 75,664 KB
実行使用メモリ 72,764 KB
平均クエリ数 1.39
最終ジャッジ日時 2023-09-23 16:05:18
合計ジャッジ時間 9,579 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
72,524 KB
testcase_01 AC 170 ms
72,764 KB
testcase_02 AC 153 ms
72,036 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 162 ms
72,076 KB
testcase_10 RE -
testcase_11 AC 161 ms
72,172 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 153 ms
71,496 KB
testcase_17 AC 150 ms
71,700 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][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