結果

問題 No.241 出席番号(1)
ユーザー GrenacheGrenache
提出日時 2015-07-12 20:10:33
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,187 bytes
コンパイル時間 3,773 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 56,460 KB
最終ジャッジ日時 2023-08-20 17:49:19
合計ジャッジ時間 9,301 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
53,548 KB
testcase_01 AC 103 ms
56,136 KB
testcase_02 AC 104 ms
56,104 KB
testcase_03 AC 103 ms
55,672 KB
testcase_04 AC 108 ms
55,956 KB
testcase_05 AC 103 ms
56,068 KB
testcase_06 AC 104 ms
55,816 KB
testcase_07 AC 102 ms
55,956 KB
testcase_08 AC 107 ms
55,940 KB
testcase_09 AC 105 ms
55,928 KB
testcase_10 AC 104 ms
56,412 KB
testcase_11 AC 102 ms
55,916 KB
testcase_12 AC 104 ms
55,844 KB
testcase_13 AC 105 ms
55,612 KB
testcase_14 AC 111 ms
55,580 KB
testcase_15 AC 111 ms
55,788 KB
testcase_16 AC 101 ms
55,852 KB
testcase_17 AC 104 ms
54,412 KB
testcase_18 AC 103 ms
55,836 KB
testcase_19 AC 102 ms
56,064 KB
testcase_20 AC 105 ms
55,828 KB
testcase_21 AC 101 ms
56,084 KB
testcase_22 AC 102 ms
56,332 KB
testcase_23 AC 112 ms
55,792 KB
testcase_24 AC 112 ms
56,116 KB
testcase_25 AC 122 ms
55,864 KB
testcase_26 AC 114 ms
56,148 KB
testcase_27 AC 105 ms
55,944 KB
testcase_28 AC 112 ms
55,620 KB
testcase_29 AC 111 ms
55,928 KB
testcase_30 AC 113 ms
55,656 KB
testcase_31 AC 130 ms
56,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder241 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] a = new int[n];
        boolean flag = true;
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        	if (i > 0 && a[i - 1] != a[i]) {
        		flag = false;
        	}
        }

        if (flag && a[0] < n) {
        	System.out.println(-1);
        } else {
        	int[] ret = new int[n];
        	for (int i = 0; i < n; i++) {
        		ret[i] = i;
        	}

        	for (; true;) {
        		for (int i = 0; i < n; i++) {
        			int r = i + (int)(Math.random() * (n - i));
        			int tmp = ret[i];
        			ret[i] = ret[r];
        			ret[r] = tmp;
        		}

        		boolean check = true;
        		for (int i = 0; i < n; i++) {
        			if (ret[i] == a[i]) {
        				check = false;
        				break;
        			}
        		}
        		
        		if (check) {
        			break;
        		}
        	}

        	for (int i = 0; i < n; i++) {
            	System.out.println(ret[i]);
            }
        }

        sc.close();
    }
}
0