結果

問題 No.694 square1001 and Permutation 3
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-06-08 23:48:05
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 826 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 71,736 KB
実行使用メモリ 71,400 KB
最終ジャッジ日時 2023-09-13 00:29:08
合計ジャッジ時間 10,417 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
44,392 KB
testcase_01 AC 120 ms
39,304 KB
testcase_02 AC 117 ms
39,416 KB
testcase_03 AC 536 ms
42,288 KB
testcase_04 AC 536 ms
41,344 KB
testcase_05 AC 547 ms
41,728 KB
testcase_06 AC 540 ms
41,984 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) a[i] = in.nextInt();

        for(int i=0; i<n; i++) {
            int cnt = 0;
            int[] t = new int[n];
            for(int j=0; j<n; j++) {
                int temp = (i+j) % n;
                t[j] = a[temp];
            }

            for(int j=0; j<n; j++) {
                for(int k=0; k<n-1; k++) {
                    if(t[k] > t[k+1]) {
                        int c = t[k];
                        t[k] = t[k+1];
                        t[k+1] = c;

                        cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }

    }
}
0