結果

問題 No.397 NO MORE KADOMATSU
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-28 23:01:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 74,064 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 02:20:05
合計ジャッジ時間 6,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
72,308 KB
testcase_01 AC 164 ms
72,792 KB
testcase_02 AC 130 ms
71,712 KB
testcase_03 AC 178 ms
72,796 KB
testcase_04 AC 164 ms
73,376 KB
testcase_05 AC 185 ms
72,632 KB
testcase_06 AC 194 ms
73,320 KB
testcase_07 AC 189 ms
73,252 KB
testcase_08 AC 179 ms
72,624 KB
testcase_09 AC 144 ms
71,400 KB
testcase_10 AC 385 ms
74,064 KB
testcase_11 AC 142 ms
71,828 KB
testcase_12 AC 172 ms
73,192 KB
testcase_13 AC 277 ms
73,676 KB
testcase_14 AC 277 ms
73,224 KB
testcase_15 AC 280 ms
73,436 KB
testcase_16 AC 133 ms
71,628 KB
testcase_17 AC 133 ms
71,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  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();
    }
    ArrayList<Integer> list1 = new ArrayList<Integer>();
    ArrayList<Integer> list2 = new ArrayList<Integer>();
    for(int i = 0; i < n; i++) {
      for(int j = i + 1; j < n; j++) {
        if(a[i] > a[j]) {
          list1.add(i);
          list2.add(j);
          int s = a[j];
          a[j] = a[i];
          a[i] = s;
        }
      }
    }
    System.out.println(list1.size());
    for(int i = 0; i < list1.size(); i++) {
      System.out.println(list1.get(i) + " " + list2.get(i));
    }
    int t = sc.nextInt();
    System.out.flush();
  }
}
0