結果

問題 No.838 Noelちゃんと星々3
ユーザー tcltktcltk
提出日時 2021-01-18 19:42:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 107,776 KB
最終ジャッジ日時 2024-05-08 08:21:46
合計ジャッジ時間 7,037 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 147 ms
89,248 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 147 ms
88,712 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 141 ms
89,088 KB
testcase_17 AC 144 ms
89,216 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 145 ms
89,216 KB
testcase_21 AC 143 ms
89,164 KB
testcase_22 AC 146 ms
89,208 KB
testcase_23 AC 145 ms
88,752 KB
testcase_24 AC 145 ms
88,832 KB
testcase_25 AC 145 ms
89,088 KB
testcase_26 AC 145 ms
89,100 KB
testcase_27 AC 145 ms
88,832 KB
testcase_28 AC 145 ms
89,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)



def main():
    N = int(input())
    Y = [-10**12] + sorted(list(map(int, input().split()))) + [10**12]

    i = 1
    v = 0
    prev = Y[0]
    while i < N+1:
        if Y[i] - prev < Y[i+1] - Y[i]:
            # 下の方が近い
            v += Y[i] - prev
            i += 1
        else:
            # 上の方が近い
            v += Y[i+1] - Y[i]
            prev = Y[i+1]
            i += 2
    print(v)

if __name__ == '__main__':
    main()
0