結果

問題 No.241 出席番号(1)
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-10 23:12:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 8,724 KB
最終ジャッジ日時 2023-09-22 10:09:12
合計ジャッジ時間 2,857 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,692 KB
testcase_01 AC 19 ms
8,696 KB
testcase_02 AC 20 ms
8,524 KB
testcase_03 AC 20 ms
8,512 KB
testcase_04 AC 19 ms
8,640 KB
testcase_05 WA -
testcase_06 AC 19 ms
8,532 KB
testcase_07 WA -
testcase_08 AC 19 ms
8,520 KB
testcase_09 AC 18 ms
8,536 KB
testcase_10 AC 18 ms
8,712 KB
testcase_11 AC 19 ms
8,492 KB
testcase_12 AC 19 ms
8,700 KB
testcase_13 AC 19 ms
8,516 KB
testcase_14 AC 18 ms
8,716 KB
testcase_15 AC 18 ms
8,552 KB
testcase_16 AC 19 ms
8,640 KB
testcase_17 WA -
testcase_18 AC 19 ms
8,680 KB
testcase_19 AC 19 ms
8,688 KB
testcase_20 AC 18 ms
8,592 KB
testcase_21 AC 20 ms
8,524 KB
testcase_22 AC 21 ms
8,648 KB
testcase_23 AC 19 ms
8,688 KB
testcase_24 AC 18 ms
8,504 KB
testcase_25 AC 19 ms
8,600 KB
testcase_26 AC 19 ms
8,724 KB
testcase_27 AC 19 ms
8,528 KB
testcase_28 AC 19 ms
8,712 KB
testcase_29 AC 20 ms
8,536 KB
testcase_30 AC 19 ms
8,568 KB
testcase_31 AC 19 ms
8,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

def read_data():
    N = int(input())
    As = [int(input()) for i in range(N)]
    return N, As

def solve(N, As):
    if N == 1:
        return [-1]
    result = [-1] * N
    freq = collections.Counter([a for a in As if a < N])
    free = [i for i in range(N) if i not in freq]
    most_com = freq.most_common()
    poss = [pos for pos, count in most_com] + free
    priority = [(0 if a not in freq else freq[a], i, a) for i, a in enumerate(As)]
    priority.sort()
    for pos in poss:
        idx = len(priority) - 1
        while priority[idx][2] == pos:
            idx -= 1
            if idx < 0:
                return [-1]
        result[priority[idx][1]] = pos
        del priority[idx]
    return result

N, As = read_data()
answer = solve(N, As)
for ans in answer:
    print(ans)
0