結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2025-09-03 17:21:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 65 ms / 5,000 ms |
コード長 | 1,270 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 82,692 KB |
実行使用メモリ | 69,972 KB |
最終ジャッジ日時 | 2025-09-03 17:21:40 |
合計ジャッジ時間 | 4,157 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right # 0~9を並び替えるならpermutationsかconbinations,N列のカテゴリを作るにはproduct from itertools import product, permutations, combinations, accumulate from functools import lru_cache # @lru_cache(maxsize=128) import operator from string import ascii_uppercase, ascii_lowercase, digits # 英字(大文字), 英字(小文字), 数字 MOD = 998244353 def II(): return int(input()) def LI(): return list(input()) def LMI(): return list(map(int, input().split())) def LMS(): return list(map(str, input().split())) def LLMI(x): return [list(map(int, input().split())) for _ in range(x)] def LLMS(x): return [list(input()) for _ in range(x)] def execute(): n = II() v = LMI() dp = [[-float('INF')] * 2 for _ in range(n+1)] dp[0][0] = 0 # 0はとっていない、1はとっている for i in range(1, n+1): for j in range(2): if j == 0: dp[i][j] = max(dp[i-1][j], dp[i-1][j^1]) else: dp[i][j] = dp[i-1][j^1] + v[i - 1] print(max(dp[-1])) if __name__ == "__main__": T = 1 for _ in range(T): execute()