結果

問題 No.999 てん vs. ほむ
ユーザー stngstng
提出日時 2022-08-17 16:07:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 304 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 96,420 KB
最終ジャッジ日時 2024-04-15 05:37:15
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,736 KB
testcase_01 AC 37 ms
52,004 KB
testcase_02 AC 36 ms
53,132 KB
testcase_03 AC 37 ms
53,344 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 37 ms
52,620 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 68 ms
86,460 KB
testcase_18 AC 68 ms
86,496 KB
testcase_19 AC 71 ms
86,256 KB
testcase_20 AC 69 ms
87,340 KB
testcase_21 AC 81 ms
95,852 KB
testcase_22 AC 76 ms
93,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]

ans = 0

l,r = 0,2*n-1

for i in range(n):
    if a[l] - a[l+1] > a[r] - a[r-1]:
        ans += a[l]-a[l+1]
        a[l],a[l+1] = 0,10**10
        l += 2
    else:
        ans += a[r]-a[r-1]
        a[r],a[r-1] = 0,10**10
        r -= 2

print(ans)
0