結果

問題 No.838 Noelちゃんと星々3
ユーザー buey_tbuey_t
提出日時 2023-04-28 12:55:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 97,664 KB
最終ジャッジ日時 2023-08-11 01:37:17
合計ジャッジ時間 9,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 215 ms
82,776 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 224 ms
82,716 KB
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 219 ms
82,644 KB
testcase_17 AC 221 ms
82,776 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 221 ms
82,568 KB
testcase_21 AC 220 ms
82,660 KB
testcase_22 RE -
testcase_23 AC 218 ms
82,652 KB
testcase_24 AC 221 ms
82,912 KB
testcase_25 AC 224 ms
82,520 KB
testcase_26 AC 220 ms
82,584 KB
testcase_27 AC 218 ms
82,500 KB
testcase_28 AC 220 ms
82,812 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