結果

問題 No.2854 -1 Subsequence
ユーザー hiro1729hiro1729
提出日時 2024-08-25 13:41:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,540 KB
実行使用メモリ 101,572 KB
最終ジャッジ日時 2024-08-25 13:41:20
合計ジャッジ時間 4,902 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
101,064 KB
testcase_01 AC 93 ms
101,152 KB
testcase_02 AC 93 ms
101,272 KB
testcase_03 AC 76 ms
89,560 KB
testcase_04 AC 107 ms
99,340 KB
testcase_05 AC 108 ms
93,280 KB
testcase_06 AC 71 ms
84,428 KB
testcase_07 AC 112 ms
99,400 KB
testcase_08 AC 56 ms
71,312 KB
testcase_09 AC 89 ms
95,660 KB
testcase_10 AC 119 ms
99,192 KB
testcase_11 AC 112 ms
99,316 KB
testcase_12 AC 111 ms
99,340 KB
testcase_13 AC 112 ms
99,604 KB
testcase_14 AC 113 ms
99,336 KB
testcase_15 AC 140 ms
99,460 KB
testcase_16 AC 116 ms
99,220 KB
testcase_17 AC 113 ms
99,216 KB
testcase_18 AC 112 ms
99,332 KB
testcase_19 AC 112 ms
99,072 KB
testcase_20 AC 110 ms
101,192 KB
testcase_21 AC 110 ms
99,648 KB
testcase_22 AC 116 ms
101,572 KB
testcase_23 AC 42 ms
54,848 KB
testcase_24 AC 42 ms
54,996 KB
testcase_25 AC 42 ms
54,404 KB
testcase_26 AC 40 ms
54,176 KB
testcase_27 AC 41 ms
54,312 KB
testcase_28 AC 46 ms
55,388 KB
testcase_29 AC 42 ms
54,716 KB
testcase_30 AC 42 ms
54,676 KB
testcase_31 AC 41 ms
53,500 KB
testcase_32 AC 41 ms
55,260 KB
testcase_33 AC 42 ms
54,996 KB
testcase_34 AC 40 ms
55,384 KB
testcase_35 AC 41 ms
54,436 KB
testcase_36 AC 41 ms
55,492 KB
testcase_37 AC 42 ms
54,556 KB
testcase_38 AC 41 ms
53,572 KB
testcase_39 AC 41 ms
54,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import defaultdict as dd
S = input
R = range
P = print
def I(): return int(S())
def M(): return map(int, S().split())
def L(): return list(M())
def O(): return list(map(int, open(0).read().split()))
def yn(b): print("Yes" if b else "No")
biga = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
smaa = "abcdefghijklmnopqrstuvwxyz"
ctoi = lambda c: ord(c) - ord('a')
itoc = lambda i: chr(ord('a') + i)
inf = 10 ** 18
mod = 998244353
def acc(a):
	b = [0]
	for i in a:
		b.append(b[-1] + i)
	return b

n = I()
a = L()
dp = [-inf] * 3 # 0 not choosed
dp[0] = 0
for i in a:
	ndp = [-inf] * 3
	ndp[0] = 0
	ndp[1] = max(dp[1], max(dp[0], dp[2]) - i)
	ndp[2] = max(dp[2], dp[1] + i)
	dp = ndp
P(max(dp[1], dp[2]))
0