結果

問題 No.45 回転寿司
ユーザー hiro_hiro_hirop
提出日時 2018-06-04 19:14:29
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 22 ms / 5,000 ms
+ 272µs
コード長 566 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-08 17:16:43
合計ジャッジ時間 2,797 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
v = list(map(int, input().split()))

que = [[0,True]] #[暫定合計値,次回食べていいか否か]
for cnt in range(len(v)):
    now_que1 = []
    now_que2 = []
    for now in que:
        if now[1]:
            now_que1.append([now[0]+v[cnt],False])
            now_que2.append([now[0],True])
        else:
            now_que2.append([now[0],True])
    now_que1.sort(key=lambda x: -x[0])
    now_que2.sort(key=lambda x: -x[0])
    que = []
    que.append(now_que1[0])
    que.append(now_que2[0])
que.sort(key=lambda x: -x[0])
print(que[0][0])
0