結果

問題 No.241 出席番号(1)
ユーザー roiti46roiti46
提出日時 2015-07-10 22:47:28
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 815 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 6,500 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-09-22 10:02:51
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 AC 11 ms
5,956 KB
testcase_10 AC 11 ms
5,932 KB
testcase_11 AC 10 ms
5,932 KB
testcase_12 AC 11 ms
5,968 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 11 ms
6,056 KB
testcase_17 WA -
testcase_18 AC 11 ms
5,952 KB
testcase_19 AC 10 ms
6,116 KB
testcase_20 AC 11 ms
5,912 KB
testcase_21 AC 10 ms
5,852 KB
testcase_22 AC 10 ms
5,868 KB
testcase_23 AC 12 ms
6,004 KB
testcase_24 AC 10 ms
5,996 KB
testcase_25 RE -
testcase_26 AC 11 ms
5,840 KB
testcase_27 AC 11 ms
5,948 KB
testcase_28 AC 10 ms
6,100 KB
testcase_29 AC 11 ms
5,896 KB
testcase_30 AC 11 ms
5,900 KB
testcase_31 AC 11 ms
5,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]
if N == 1:
        print -1
        exit()

hist = [0] * N
for a in A:
        hist[a] += 1

if N in hist:
        print -1
        exit()

priority = sorted([[h, i] for i, h in enumerate(hist)], reverse = True)
used = [False] * N
ans = [-1] * N
for h, i in priority:
        for j in xrange(N):
                if A[j] != i and not used[j]:
                        ans[j] = i
                        used[j] = True
                        break
        else:
                for j in xrange(N):
                        if not used[j]:
                                ans[j] = i
                                used[j] = True
                                break

if -1 not in ans:
        for a in ans:
                print a
else:
        print -1
0