結果

問題 No.2854 -1 Subsequence
ユーザー ntudantuda
提出日時 2024-08-31 12:23:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 104,596 KB
最終ジャッジ日時 2024-08-31 12:24:05
合計ジャッジ時間 5,656 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
101,196 KB
testcase_01 AC 85 ms
100,956 KB
testcase_02 AC 86 ms
101,292 KB
testcase_03 AC 69 ms
88,988 KB
testcase_04 AC 92 ms
104,520 KB
testcase_05 AC 80 ms
93,012 KB
testcase_06 AC 59 ms
81,352 KB
testcase_07 AC 92 ms
104,596 KB
testcase_08 AC 49 ms
69,512 KB
testcase_09 AC 77 ms
95,424 KB
testcase_10 AC 104 ms
102,280 KB
testcase_11 AC 105 ms
102,376 KB
testcase_12 AC 104 ms
102,160 KB
testcase_13 AC 103 ms
102,228 KB
testcase_14 AC 103 ms
102,428 KB
testcase_15 AC 104 ms
102,224 KB
testcase_16 AC 103 ms
102,220 KB
testcase_17 AC 105 ms
102,144 KB
testcase_18 AC 131 ms
102,376 KB
testcase_19 AC 105 ms
102,160 KB
testcase_20 AC 102 ms
102,928 KB
testcase_21 AC 102 ms
102,324 KB
testcase_22 AC 107 ms
100,328 KB
testcase_23 AC 36 ms
53,816 KB
testcase_24 AC 35 ms
52,284 KB
testcase_25 AC 36 ms
52,480 KB
testcase_26 AC 36 ms
52,124 KB
testcase_27 AC 35 ms
52,416 KB
testcase_28 AC 36 ms
52,280 KB
testcase_29 AC 35 ms
52,216 KB
testcase_30 AC 35 ms
53,520 KB
testcase_31 AC 35 ms
52,876 KB
testcase_32 AC 34 ms
53,292 KB
testcase_33 AC 36 ms
52,364 KB
testcase_34 AC 37 ms
52,572 KB
testcase_35 AC 37 ms
52,680 KB
testcase_36 AC 36 ms
53,468 KB
testcase_37 AC 42 ms
52,404 KB
testcase_38 AC 36 ms
52,676 KB
testcase_39 AC 37 ms
53,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 10
dp = [-A[0], -INF]
dp2 = dp[:]
#  dp[i]:= i=0 前回値変更したのが奇数、i=1 前回値変更したのが偶数 の最大値
for i in range(1, N):
    dp2[0] = max(dp2[0], - A[i], dp[1] - A[i])
    dp2[1] = max(dp2[1], dp[0] + A[i])
    dp = dp2[:]
print(max(dp))
0