結果
| 問題 | No.2854 -1 Subsequence |
| コンテスト | |
| ユーザー |
prin_kemkem
|
| 提出日時 | 2024-08-25 14:09:19 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 261 ms / 2,000 ms |
| + 328µs | |
| コード長 | 780 bytes |
| 記録 | |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 96,112 KB |
| 実行使用メモリ | 136,324 KB |
| 最終ジャッジ日時 | 2026-07-16 10:35:49 |
| 合計ジャッジ時間 | 13,222 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
ソースコード
from collections import defaultdict, deque, Counter
# from functools import cache
# import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
# from more_itertools import distinct_permutations
from heapq import heapify, heappop, heappush
import math
import bisect
from pprint import pprint
from random import randint, shuffle, randrange
import sys
# sys.setrecursionlimit(200000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)
#################################################
N = int(input())
A = list(map(int, input().split()))
dp = [0, -inf, -inf]
for a in A:
dp = [0, max(dp[1], dp[0]-a, dp[2]-a), max(dp[2], dp[1]+a)]
print(max(dp[1:]))
prin_kemkem