結果

問題 No.2854 -1 Subsequence
ユーザー prd_xxxprd_xxx
提出日時 2024-08-25 13:52:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 265 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 104,692 KB
最終ジャッジ日時 2024-08-25 13:52:31
合計ジャッジ時間 4,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
99,856 KB
testcase_01 AC 83 ms
98,368 KB
testcase_02 AC 80 ms
99,572 KB
testcase_03 AC 61 ms
81,444 KB
testcase_04 AC 89 ms
104,692 KB
testcase_05 AC 67 ms
87,388 KB
testcase_06 AC 56 ms
76,180 KB
testcase_07 AC 87 ms
104,208 KB
testcase_08 AC 46 ms
65,480 KB
testcase_09 AC 76 ms
90,672 KB
testcase_10 AC 98 ms
102,392 KB
testcase_11 AC 100 ms
102,432 KB
testcase_12 AC 99 ms
102,416 KB
testcase_13 AC 99 ms
102,296 KB
testcase_14 AC 123 ms
102,360 KB
testcase_15 AC 99 ms
102,424 KB
testcase_16 AC 95 ms
102,088 KB
testcase_17 AC 98 ms
102,064 KB
testcase_18 AC 101 ms
102,248 KB
testcase_19 AC 101 ms
102,428 KB
testcase_20 AC 98 ms
102,624 KB
testcase_21 AC 99 ms
101,868 KB
testcase_22 AC 101 ms
100,576 KB
testcase_23 AC 34 ms
53,108 KB
testcase_24 AC 35 ms
52,280 KB
testcase_25 AC 36 ms
53,444 KB
testcase_26 AC 36 ms
52,156 KB
testcase_27 AC 35 ms
52,432 KB
testcase_28 AC 40 ms
52,404 KB
testcase_29 AC 35 ms
52,480 KB
testcase_30 AC 35 ms
52,688 KB
testcase_31 AC 38 ms
53,140 KB
testcase_32 AC 36 ms
52,316 KB
testcase_33 AC 37 ms
52,804 KB
testcase_34 AC 35 ms
52,088 KB
testcase_35 AC 34 ms
52,152 KB
testcase_36 AC 35 ms
52,700 KB
testcase_37 AC 35 ms
53,140 KB
testcase_38 AC 35 ms
52,076 KB
testcase_39 AC 35 ms
52,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

if all(a > 0 for a in A) and all(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))
0