結果

問題 No.258 回転寿司(2)
ユーザー ayaoniayaoni
提出日時 2020-12-28 10:22:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 55,628 KB
最終ジャッジ日時 2024-04-10 08:48:29
合計ジャッジ時間 6,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
54,676 KB
testcase_01 WA -
testcase_02 AC 41 ms
53,380 KB
testcase_03 AC 38 ms
53,008 KB
testcase_04 AC 37 ms
52,948 KB
testcase_05 WA -
testcase_06 AC 38 ms
54,548 KB
testcase_07 AC 38 ms
53,164 KB
testcase_08 AC 40 ms
53,380 KB
testcase_09 AC 38 ms
52,484 KB
testcase_10 AC 38 ms
53,960 KB
testcase_11 AC 38 ms
53,192 KB
testcase_12 WA -
testcase_13 AC 38 ms
52,644 KB
testcase_14 AC 39 ms
53,704 KB
testcase_15 WA -
testcase_16 AC 37 ms
52,960 KB
testcase_17 AC 39 ms
53,928 KB
testcase_18 AC 40 ms
54,968 KB
testcase_19 WA -
testcase_20 AC 38 ms
53,880 KB
testcase_21 WA -
testcase_22 AC 36 ms
52,488 KB
testcase_23 AC 38 ms
53,464 KB
testcase_24 AC 37 ms
52,864 KB
testcase_25 AC 38 ms
52,248 KB
testcase_26 AC 39 ms
54,332 KB
testcase_27 WA -
testcase_28 AC 41 ms
53,860 KB
testcase_29 WA -
testcase_30 AC 39 ms
52,692 KB
testcase_31 WA -
testcase_32 AC 39 ms
53,684 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 40 ms
52,700 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 39 ms
54,596 KB
testcase_40 AC 38 ms
52,996 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 38 ms
54,192 KB
testcase_44 WA -
testcase_45 AC 38 ms
52,828 KB
testcase_46 AC 39 ms
52,192 KB
testcase_47 AC 40 ms
54,372 KB
testcase_48 AC 40 ms
52,688 KB
testcase_49 AC 40 ms
52,896 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 40 ms
54,048 KB
testcase_53 AC 39 ms
54,112 KB
testcase_54 AC 38 ms
53,076 KB
testcase_55 WA -
testcase_56 AC 38 ms
53,700 KB
testcase_57 AC 37 ms
52,732 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 39 ms
54,360 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 42 ms
54,608 KB
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 41 ms
53,792 KB
testcase_70 AC 40 ms
52,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
V = [0]+LI()

if N == 1:
    print(V[1])
    print(1)
    exit()

dp = [0]*(N+1)
prev = [0]*(N+1)
dp[1] = V[1]
dp[2] = V[2]
for i in range(3,N+1):
    if dp[i-2] >= dp[i-3]:
        prev[i] = i-2
        dp[i] = dp[i-2]+V[i]
    else:
        prev[i] = i-3
        dp[i] = dp[i-3]+V[i]

if dp[-1] >= dp[-2]:
    ANS = [N]
    while prev[N] != 0:
        ANS.append(prev[N])
        N = prev[N]
    ANS.reverse()
    print(dp[-1])
    print(*ANS)
else:
    ANS = [N-1]
    while prev[N] != 0:
        ANS.append(prev[N])
        N = prev[N]
    ANS.reverse()
    print(dp[-2])
    print(*ANS)
0