結果

問題 No.397 NO MORE KADOMATSU
ユーザー kano_townkano_town
提出日時 2016-07-15 23:31:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 4,986 ms
コンパイル使用メモリ 75,756 KB
実行使用メモリ 73,624 KB
平均クエリ数 414.83
最終ジャッジ日時 2023-09-24 00:17:55
合計ジャッジ時間 8,689 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 181 ms
72,720 KB
testcase_01 AC 177 ms
73,048 KB
testcase_02 AC 185 ms
73,052 KB
testcase_03 AC 253 ms
73,368 KB
testcase_04 AC 190 ms
72,632 KB
testcase_05 AC 240 ms
72,720 KB
testcase_06 AC 213 ms
70,896 KB
testcase_07 AC 209 ms
72,676 KB
testcase_08 AC 193 ms
72,576 KB
testcase_09 AC 161 ms
72,596 KB
testcase_10 AC 158 ms
72,044 KB
testcase_11 AC 157 ms
71,912 KB
testcase_12 AC 207 ms
72,476 KB
testcase_13 AC 295 ms
73,424 KB
testcase_14 AC 285 ms
73,624 KB
testcase_15 AC 298 ms
73,180 KB
testcase_16 AC 182 ms
72,928 KB
testcase_17 AC 182 ms
73,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder397 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), cnt = 0;
        int[] a = new int[n];
        int[] res = new int[10000];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] < a[j]) {
                    int buf = a[i];
                    a[i] = a[j];
                    a[j] = buf;
                    res[cnt * 2] = i;
                    res[cnt * 2 + 1] = j;
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
        for (int i = 0; i < cnt; i++) {
            System.out.println(res[i * 2] + " " + res[i * 2 + 1]);
        }
        System.out.flush();
        sc.nextInt();
    }
}
0