結果

問題 No.837 Noelちゃんと星々2
ユーザー kekurekekure
提出日時 2019-07-12 16:42:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 785 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 100,924 KB
最終ジャッジ日時 2024-04-28 22:10:37
合計ジャッジ時間 6,977 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def cnt_d(line_one, line_two, array, array_length):
    d = 0
    for i in range(0, line_one + 1):
        d += array[line_one] - array[i]
    i = line_one + 1
    while array[i] - array[line_one] < array[line_two] - array[i]:
        d += array[i] - array[line_one]
        i += 1
    while i < line_two:
        d += array[line_two] - array[i]
        i += 1
    for i in range(line_two, array_length):
        d += array[i] - array[line_two]

    return d


N = int(input())
nums = [int(i) for i in input().split()]
nums.sort()
d_min = cnt_d(0, 1, nums, N)

if any([x != nums[0] for x in nums]):
    for a in range(0, N - 1):
        for b in range(a + 1, N):
            d = cnt_d(a, b, nums, N)
            if d_min > d:
                d_min = d
else:
    d_min = 1

print(d_min)
0