結果

問題 No.609 Noelちゃんと星々
コンテスト
ユーザー GrayCoder
提出日時 2017-12-09 10:14:25
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 496 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 605 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 32,116 KB
最終ジャッジ日時 2026-05-23 19:09:28
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter

def main():
    N = int(input())
    Y = tuple(map(int, input().split()))

    if N == 1:
        print(Y[0])
        return
    elif N == 2:
        n = Y[:]
    else:
        n = sorted(Y)
        max_i = n.index(max(n))
        n = n[:max_i][::-1]
        min_i = n.index(min(n))
        n = n[:min_i]

    counter = Counter(n)
    reference = counter.most_common()[0][0]
    dist = 0
    for i in Y:
        dist += abs(reference - i)
    print(dist)

main()
0