結果

問題 No.258 回転寿司(2)
ユーザー tnoda_tnoda_
提出日時 2015-08-29 15:06:25
言語 Python2
(2.7.18)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-11-06 18:54:01
合計ジャッジ時間 4,212 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 67
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
v = [0]
v.extend(map(int, raw_input().split()))
a = [0] * (N+1)
b = [0] * (N+1)
a_sushi = [None] * (N+1)
b_sushi = [None] * (N+1)
a_sushi[0] = []
b_sushi[0] = []
for i in xrange(1, N+1):
    a[i] = v[i] + b[i-1]
    a_sushi[i] = b_sushi[i-1] + [i]
    if a[i-1] > b[i-1]:
        b[i] = a[i-1]
        b_sushi[i] = a_sushi[i-1]
    else:
        b[i] = b[i-1]
        b_sushi[i] = b_sushi[i-1]
if a[N] > b[N]:
    print(a[N])
    print(' '.join(map(str, a_sushi[N])))
else:
    print(b[N])
    print(' '.join(map(str, b_sushi[N])))
0