結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2023-08-15 08:20:22 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-23 14:13:19 |
合計ジャッジ時間 | 2,359 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
import bisect,collections,itertools,math,functools,heapq import sys #sys.setrecursionlimit(10**6) def I(): return int(sys.stdin.readline().rstrip()) def IN(): return int(input()) def LIN(): return list(map(int, input().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LF(): return list(map(float,sys.stdin.readline().rstrip().split())) def SI(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) """ 方針 dp """ N=I() V=LI() dp = [[0,0] for _ in range(N+1)] for i in range(N): v = V[i] dp[i+1][0] = max(dp[i][1] + v, dp[i][0]) dp[i+1][1] = max(dp[i][0], dp[i][1]) print(max(dp[N]))