結果

問題 No.258 回転寿司(2)
ユーザー ああいいああいい
提出日時 2021-12-04 20:55:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 803 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 12,536 KB
最終ジャッジ日時 2023-09-21 09:38:36
合計ジャッジ時間 7,088 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
12,284 KB
testcase_01 AC 32 ms
12,536 KB
testcase_02 AC 22 ms
9,900 KB
testcase_03 AC 16 ms
8,216 KB
testcase_04 AC 18 ms
9,052 KB
testcase_05 AC 19 ms
9,316 KB
testcase_06 AC 27 ms
11,488 KB
testcase_07 AC 17 ms
8,516 KB
testcase_08 AC 18 ms
9,256 KB
testcase_09 AC 17 ms
8,476 KB
testcase_10 AC 17 ms
8,280 KB
testcase_11 AC 17 ms
8,716 KB
testcase_12 AC 19 ms
9,096 KB
testcase_13 AC 17 ms
8,300 KB
testcase_14 AC 26 ms
10,992 KB
testcase_15 AC 18 ms
8,488 KB
testcase_16 AC 17 ms
8,508 KB
testcase_17 AC 17 ms
8,488 KB
testcase_18 AC 29 ms
11,764 KB
testcase_19 AC 16 ms
8,184 KB
testcase_20 AC 22 ms
10,168 KB
testcase_21 AC 27 ms
11,192 KB
testcase_22 AC 16 ms
8,172 KB
testcase_23 AC 16 ms
8,252 KB
testcase_24 AC 16 ms
8,200 KB
testcase_25 AC 16 ms
8,248 KB
testcase_26 AC 22 ms
10,000 KB
testcase_27 AC 18 ms
8,612 KB
testcase_28 AC 31 ms
12,464 KB
testcase_29 AC 19 ms
9,004 KB
testcase_30 AC 17 ms
8,472 KB
testcase_31 AC 17 ms
8,380 KB
testcase_32 AC 18 ms
8,556 KB
testcase_33 AC 26 ms
10,728 KB
testcase_34 AC 21 ms
9,616 KB
testcase_35 AC 20 ms
9,444 KB
testcase_36 AC 17 ms
8,284 KB
testcase_37 AC 17 ms
8,268 KB
testcase_38 AC 18 ms
8,728 KB
testcase_39 AC 18 ms
8,804 KB
testcase_40 AC 21 ms
9,944 KB
testcase_41 AC 25 ms
10,632 KB
testcase_42 AC 17 ms
8,488 KB
testcase_43 AC 17 ms
8,360 KB
testcase_44 AC 27 ms
11,220 KB
testcase_45 AC 22 ms
10,132 KB
testcase_46 AC 15 ms
8,300 KB
testcase_47 AC 23 ms
10,340 KB
testcase_48 AC 16 ms
8,396 KB
testcase_49 AC 17 ms
8,552 KB
testcase_50 AC 15 ms
7,812 KB
testcase_51 AC 21 ms
9,768 KB
testcase_52 AC 19 ms
9,500 KB
testcase_53 AC 16 ms
8,352 KB
testcase_54 AC 22 ms
10,064 KB
testcase_55 AC 30 ms
12,352 KB
testcase_56 AC 22 ms
10,148 KB
testcase_57 AC 17 ms
8,244 KB
testcase_58 AC 20 ms
9,416 KB
testcase_59 AC 29 ms
11,848 KB
testcase_60 AC 16 ms
8,404 KB
testcase_61 AC 24 ms
10,600 KB
testcase_62 AC 18 ms
8,748 KB
testcase_63 AC 21 ms
9,972 KB
testcase_64 AC 30 ms
12,444 KB
testcase_65 AC 21 ms
10,188 KB
testcase_66 AC 16 ms
8,304 KB
testcase_67 AC 26 ms
11,004 KB
testcase_68 AC 25 ms
11,136 KB
testcase_69 AC 22 ms
10,356 KB
testcase_70 AC 17 ms
8,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
V = list(map(int,input().split()))

dp = [[0] * 2 for _ in range(N)]
dplist = [[[],[]] for _ in range(N)]
dp[0][1] = V[0]
dplist[0][1].append(1)
for i in range(1,N):
    if dp[i-1][0] < dp[i-1][1]:
        dp[i][0] = dp[i-1][1]
        #dplist[i][0] = copy(dplist[i-1][1])
        dplist[i][0] = dplist[i-1][1].copy()
    else:
        dp[i][0] = dp[i-1][0]
        #dplist[i][0] = copy(dplist[i-1][0])
        dplist[i][0] = dplist[i-1][0].copy()
    dp[i][1] = dp[i-1][0] + V[i]
    #dplist[i][1] = copy(dplist[i-1][0])
    dplist[i][1] = dplist[i-1][0].copy()
    dplist[i][1].append(i+1)
if dp[N-1][0] > dp[N-1][1]:
    print(dp[N-1][0])
    for i in dplist[N-1][0]:
        print(i,end=' ')
else:
    print(dp[N-1][1])
    for i in dplist[N-1][1]:
        print(i,end=' ')
print()
0