結果

問題 No.241 出席番号(1)
ユーザー chocoruskchocorusk
提出日時 2020-09-18 20:24:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 457 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-22 08:12:09
合計ジャッジ時間 3,883 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

n=int(readline())
a=list(map(int, read().split()))
c=[0]*n
for x in a:
    if x<n:
        c[x]+=1
if n in c:
    print(-1)
    exit()
ans=[-1]*n
for _ in range(n):
    i=c.index(max(c))
    c[i]=-1
    for j, x in enumerate(a):
        if x!=i and ans[j]==-1:
            ans[j]=i
            c[x]-=1
            break
for x in ans:
    print(x)
0