結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー | crazybbb3 |
提出日時 | 2016-11-27 17:58:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 162 ms / 2,000 ms |
コード長 | 2,204 bytes |
コンパイル時間 | 2,970 ms |
コンパイル使用メモリ | 77,136 KB |
実行使用メモリ | 70,416 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2023-09-24 00:43:43 |
合計ジャッジ時間 | 5,870 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 106 ms
68,428 KB |
testcase_01 | AC | 107 ms
69,428 KB |
testcase_02 | AC | 68 ms
66,020 KB |
testcase_03 | AC | 110 ms
69,028 KB |
testcase_04 | AC | 103 ms
68,352 KB |
testcase_05 | AC | 121 ms
69,200 KB |
testcase_06 | AC | 129 ms
68,924 KB |
testcase_07 | AC | 122 ms
68,652 KB |
testcase_08 | AC | 107 ms
68,260 KB |
testcase_09 | AC | 68 ms
65,172 KB |
testcase_10 | AC | 162 ms
70,416 KB |
testcase_11 | AC | 64 ms
65,348 KB |
testcase_12 | AC | 143 ms
70,340 KB |
testcase_13 | AC | 154 ms
70,132 KB |
testcase_14 | AC | 149 ms
69,816 KB |
testcase_15 | AC | 144 ms
68,608 KB |
testcase_16 | AC | 66 ms
65,668 KB |
testcase_17 | AC | 65 ms
63,204 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; void solve() throws IOException { int n = ni(); int[] a = nia(n); ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1 - i; j++) { if (a[j] > a[j + 1]) { list.add(j); int tmp = a[j]; a[j] = a[j + 1]; a[j + 1] = tmp; } } } out.println(list.size()); for (int i = 0; i < list.size(); i++) { out.println(list.get(i) + " " + (list.get(i) + 1)); } } String ns() throws IOException { while (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine(), " "); } return tok.nextToken(); } int ni() throws IOException { return Integer.parseInt(ns()); } long nl() throws IOException { return Long.parseLong(ns()); } double nd() throws IOException { return Double.parseDouble(ns()); } String[] nsa(int n) throws IOException { String[] res = new String[n]; for (int i = 0; i < n; i++) { res[i] = ns(); } return res; } int[] nia(int n) throws IOException { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = ni(); } return res; } long[] nla(int n) throws IOException { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nl(); } return res; } public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); tok = new StringTokenizer(""); Main main = new Main(); main.solve(); out.close(); } }