結果
問題 |
No.2854 -1 Subsequence
|
ユーザー |
![]() |
提出日時 | 2024-08-31 11:47:47 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 345 bytes |
コンパイル時間 | 444 ms |
コンパイル使用メモリ | 82,792 KB |
実行使用メモリ | 104,516 KB |
最終ジャッジ日時 | 2024-08-31 11:47:54 |
合計ジャッジ時間 | 6,804 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 40 |
ソースコード
N = int(input()) A = list(map(int, input().split())) INF = 10 ** 10 dp = [-A[0], -INF] # dp[i]:= i=0 前回値変更したのが奇数、i=1 前回値変更したのが偶数 の最大値 print(dp) for i in range(1, N): dp2 = dp[:] dp2[0] = max(dp2[0], dp[1] - A[i]) dp2[1] = max(dp2[1], dp[0] + A[i]) dp = dp2 print(max(dp))