結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2022-10-14 14:27:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 5,000 ms |
| コード長 | 625 bytes |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-06-26 12:37:54 |
| 合計ジャッジ時間 | 2,591 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
def main():
N = int(input())
V = list(map(int, input().split()))
max_delicious = [[0, 0] for _ in range(N+1)]
max_delicious[1] = [V[0], 1]
for idx, value in enumerate(V[1:], 2):
if max_delicious[idx-1][1]:
if max_delicious[idx-2][0] + value > max_delicious[idx-1][0]:
max_delicious[idx] = [max_delicious[idx-2][0] + value, 1]
else:
max_delicious[idx] = [max_delicious[idx-1][0], 0]
else:
max_delicious[idx] = [max_delicious[idx-1][0] + value, 1]
print(max_delicious[N][0])
if __name__ == "__main__":
main()