結果

問題 No.258 回転寿司(2)
ユーザー convexineqconvexineq
提出日時 2021-05-06 04:40:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 76,352 KB
最終ジャッジ日時 2023-10-11 21:56:58
合計ジャッジ時間 11,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,340 KB
testcase_01 AC 84 ms
76,352 KB
testcase_02 AC 81 ms
76,096 KB
testcase_03 AC 75 ms
71,504 KB
testcase_04 AC 76 ms
71,212 KB
testcase_05 AC 77 ms
71,336 KB
testcase_06 AC 84 ms
76,044 KB
testcase_07 AC 76 ms
71,588 KB
testcase_08 AC 76 ms
71,084 KB
testcase_09 AC 75 ms
71,228 KB
testcase_10 AC 73 ms
71,304 KB
testcase_11 AC 75 ms
71,288 KB
testcase_12 AC 74 ms
71,532 KB
testcase_13 AC 73 ms
71,160 KB
testcase_14 AC 82 ms
76,136 KB
testcase_15 AC 76 ms
71,068 KB
testcase_16 AC 73 ms
71,536 KB
testcase_17 AC 73 ms
71,416 KB
testcase_18 AC 82 ms
76,168 KB
testcase_19 AC 74 ms
71,080 KB
testcase_20 AC 82 ms
75,940 KB
testcase_21 AC 82 ms
76,192 KB
testcase_22 AC 74 ms
71,400 KB
testcase_23 AC 73 ms
71,252 KB
testcase_24 AC 73 ms
71,080 KB
testcase_25 AC 73 ms
71,492 KB
testcase_26 AC 80 ms
76,084 KB
testcase_27 AC 76 ms
71,072 KB
testcase_28 AC 81 ms
76,180 KB
testcase_29 AC 77 ms
71,280 KB
testcase_30 AC 74 ms
71,268 KB
testcase_31 AC 75 ms
71,488 KB
testcase_32 AC 75 ms
71,440 KB
testcase_33 AC 82 ms
75,912 KB
testcase_34 AC 80 ms
75,728 KB
testcase_35 AC 75 ms
71,308 KB
testcase_36 AC 74 ms
71,064 KB
testcase_37 AC 73 ms
71,288 KB
testcase_38 AC 76 ms
71,284 KB
testcase_39 AC 74 ms
71,212 KB
testcase_40 AC 83 ms
76,068 KB
testcase_41 AC 82 ms
76,180 KB
testcase_42 AC 76 ms
71,440 KB
testcase_43 AC 75 ms
71,292 KB
testcase_44 AC 81 ms
76,176 KB
testcase_45 AC 80 ms
76,104 KB
testcase_46 AC 73 ms
71,484 KB
testcase_47 AC 82 ms
76,072 KB
testcase_48 AC 77 ms
71,208 KB
testcase_49 AC 77 ms
71,304 KB
testcase_50 AC 75 ms
71,396 KB
testcase_51 AC 82 ms
75,968 KB
testcase_52 AC 78 ms
71,208 KB
testcase_53 AC 73 ms
71,512 KB
testcase_54 AC 81 ms
76,068 KB
testcase_55 AC 83 ms
76,328 KB
testcase_56 AC 80 ms
75,968 KB
testcase_57 AC 75 ms
71,304 KB
testcase_58 AC 77 ms
71,068 KB
testcase_59 AC 85 ms
76,172 KB
testcase_60 AC 74 ms
71,564 KB
testcase_61 AC 84 ms
76,168 KB
testcase_62 AC 76 ms
71,284 KB
testcase_63 AC 80 ms
76,012 KB
testcase_64 AC 84 ms
76,136 KB
testcase_65 AC 81 ms
76,072 KB
testcase_66 AC 73 ms
71,432 KB
testcase_67 AC 83 ms
76,152 KB
testcase_68 AC 83 ms
76,352 KB
testcase_69 AC 81 ms
76,004 KB
testcase_70 AC 75 ms
71,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())
par = [-1]*n
dp = [0]*n
for i,ai in enumerate(a):
    if ai > dp[i]:
        dp[i] = ai
        par[i] = -1
    for j in range(2,4):
        if i+j >= n: continue
        if dp[i+j] < dp[i] + a[i+j]:
            dp[i+j] = dp[i] + a[i+j]
            par[i+j] = i
idx = max(range(n), key=lambda i:dp[i])
print(dp[idx])
ans = []
while idx >= 0:
    ans.append(idx+1)
    idx = par[idx]
print(*ans[::-1])
0