結果

問題 No.45 回転寿司
ユーザー Tsubasa
提出日時 2018-02-02 21:00:03
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 645 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 579 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 21,504 KB
最終ジャッジ日時 2026-06-04 17:54:08
合計ジャッジ時間 13,345 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import array

N = None
dp = []
sushi_list = None

def eat_sushi(index, is_ate):
  if index == N:
    return 0

  if dp[is_ate][index] != -1:
    return dp[is_ate][index]

  if is_ate == 0:
    return max(
      eat_sushi(index+1, 1) + sushi_list[index],
      eat_sushi(index+1, 0)
    )
  else:
    return eat_sushi(index+1, 0)

def main():
  global N
  global dp
  global sushi_list

  N = int(input())
  sushi_list = array.array("Q", list(map(
    int, input().split()
  )))

  for is_ate in range(2):
    dp.append([])
    for time in range(N):
      dp[is_ate].append(-1)

  print(max(
    eat_sushi(0, 0),
    eat_sushi(1, 0)
  ))

main()
0