結果
| 問題 | No.2854 -1 Subsequence | 
| コンテスト | |
| ユーザー |  prd_xxx | 
| 提出日時 | 2024-08-25 13:50:27 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 263 bytes | 
| コンパイル時間 | 233 ms | 
| コンパイル使用メモリ | 82,268 KB | 
| 実行使用メモリ | 104,480 KB | 
| 最終ジャッジ日時 | 2024-08-25 13:50:32 | 
| 合計ジャッジ時間 | 4,301 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 39 WA * 1 | 
ソースコード
N = int(input())
A = list(map(int,input().split()))
if all(a > 0 for a in A) and (a>=b for a,b in zip(A,A[1:])):
    print(-A[-1])
    exit()
INF = 10**18
p = -INF
m = 0
for a in A:
    np = max(p, m - a)
    nm = max(m, p + a)
    p,m = np,nm
print(max(p,m))
            
            
            
        