結果

問題 No.838 Noelちゃんと星々3
ユーザー buey_tbuey_t
提出日時 2023-04-28 12:55:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 104,192 KB
最終ジャッジ日時 2024-04-28 18:47:53
合計ジャッジ時間 6,611 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 148 ms
84,992 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 140 ms
84,992 KB
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 146 ms
84,992 KB
testcase_17 AC 147 ms
84,736 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 146 ms
84,864 KB
testcase_21 AC 144 ms
84,992 KB
testcase_22 RE -
testcase_23 AC 147 ms
84,992 KB
testcase_24 AC 151 ms
84,736 KB
testcase_25 AC 147 ms
84,736 KB
testcase_26 AC 143 ms
84,992 KB
testcase_27 AC 143 ms
84,992 KB
testcase_28 AC 145 ms
84,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
from copy import deepcopy
import copy
import random
from random import randrange
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
#tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
from functools import lru_cache, reduce
#@lru_cache(maxsize=None)
from operator import add,sub,mul,xor,and_,or_,itemgetter
import sys
input = sys.stdin.readline
# .rstrip()
INF = 10**18
mod1 = 10**9+7
mod2 = 998244353

#DecimalならPython
#再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!


'''
二分探索の可能性はある
ソートしていい感じにやりたいけど
動かさないといけないので、厄介
動かすか、他を動かしてくるかという
貪欲でいけるんかな
いけそう
'''

N = int(input())
Y = list(map(int, input().split()))

Y.sort()

f = 0
ans = 0
for i in range(N):
    if f == 0:
        ans += Y[i+1]-Y[i]
        f = 1
    elif f == 1:
        f = 2
    else:
        if i == N-1:
            ans += Y[i]-Y[i-1]
            break
        
        if Y[i]-Y[i-1] < Y[i+1]-Y[i]:
            ans += Y[i]-Y[i-1]
            f = 0
        else:
            ans += Y[i+1]-Y[i]
            f = 1

print(ans)
























0