結果

問題 No.258 回転寿司(2)
ユーザー roiti46roiti46
提出日時 2015-07-31 22:38:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 460 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 6,512 KB
実行使用メモリ 10,736 KB
最終ジャッジ日時 2023-08-06 15:39:31
合計ジャッジ時間 15,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 458 ms
10,468 KB
testcase_01 AC 460 ms
10,736 KB
testcase_02 AC 194 ms
8,060 KB
testcase_03 AC 14 ms
6,052 KB
testcase_04 AC 96 ms
6,884 KB
testcase_05 AC 115 ms
7,180 KB
testcase_06 AC 348 ms
9,588 KB
testcase_07 AC 48 ms
6,376 KB
testcase_08 AC 107 ms
7,092 KB
testcase_09 AC 54 ms
6,436 KB
testcase_10 AC 19 ms
6,068 KB
testcase_11 AC 65 ms
6,708 KB
testcase_12 AC 94 ms
7,016 KB
testcase_13 AC 44 ms
6,352 KB
testcase_14 AC 308 ms
9,260 KB
testcase_15 AC 54 ms
6,464 KB
testcase_16 AC 51 ms
6,480 KB
testcase_17 AC 50 ms
6,500 KB
testcase_18 AC 381 ms
9,808 KB
testcase_19 AC 13 ms
5,952 KB
testcase_20 AC 220 ms
8,096 KB
testcase_21 AC 328 ms
9,388 KB
testcase_22 AC 12 ms
5,960 KB
testcase_23 AC 12 ms
6,136 KB
testcase_24 AC 12 ms
5,968 KB
testcase_25 AC 12 ms
5,940 KB
testcase_26 AC 190 ms
7,952 KB
testcase_27 AC 57 ms
6,568 KB
testcase_28 AC 453 ms
10,488 KB
testcase_29 AC 77 ms
6,868 KB
testcase_30 AC 21 ms
6,148 KB
testcase_31 AC 20 ms
6,136 KB
testcase_32 AC 57 ms
6,532 KB
testcase_33 AC 261 ms
8,772 KB
testcase_34 AC 156 ms
7,608 KB
testcase_35 AC 131 ms
7,336 KB
testcase_36 AC 23 ms
6,316 KB
testcase_37 AC 20 ms
6,112 KB
testcase_38 AC 70 ms
6,824 KB
testcase_39 AC 65 ms
6,660 KB
testcase_40 AC 189 ms
7,968 KB
testcase_41 AC 269 ms
8,732 KB
testcase_42 AC 53 ms
6,424 KB
testcase_43 AC 32 ms
6,196 KB
testcase_44 AC 318 ms
9,324 KB
testcase_45 AC 208 ms
8,040 KB
testcase_46 AC 12 ms
5,940 KB
testcase_47 AC 217 ms
8,172 KB
testcase_48 AC 28 ms
6,144 KB
testcase_49 AC 54 ms
6,508 KB
testcase_50 AC 13 ms
6,024 KB
testcase_51 AC 165 ms
7,636 KB
testcase_52 AC 133 ms
7,320 KB
testcase_53 AC 22 ms
6,140 KB
testcase_54 AC 205 ms
8,028 KB
testcase_55 AC 445 ms
10,524 KB
testcase_56 AC 207 ms
8,072 KB
testcase_57 AC 28 ms
6,140 KB
testcase_58 AC 128 ms
7,388 KB
testcase_59 AC 384 ms
9,904 KB
testcase_60 AC 16 ms
6,140 KB
testcase_61 AC 253 ms
8,452 KB
testcase_62 AC 60 ms
6,584 KB
testcase_63 AC 185 ms
7,960 KB
testcase_64 AC 446 ms
10,624 KB
testcase_65 AC 198 ms
8,112 KB
testcase_66 AC 13 ms
6,044 KB
testcase_67 AC 293 ms
9,068 KB
testcase_68 AC 308 ms
9,220 KB
testcase_69 AC 240 ms
8,428 KB
testcase_70 AC 49 ms
6,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
N = int(raw_input())
V = map(int, raw_input().split())

dp = [[[0, []], [0, []]] for i in xrange(N)]
dp[0][0] = [V[0], [1]]
for i in xrange(1, N):
    dp[i][0] = copy.deepcopy(dp[i - 1][1])
    dp[i][0][0] += V[i]
    dp[i][0][1].append(i + 1)

    if dp[i - 1][0][0] >= dp[i - 1][1][0]:
        dp[i][1] = copy.deepcopy(dp[i - 1][0])
    else:
        dp[i][1] = copy.deepcopy(dp[i - 1][1])

if dp[N - 1][0][0] >= dp[N - 1][1][0]:
    print dp[N - 1][0][0]
    print " ".join(map(str, dp[N - 1][0][1]))
else:
    print dp[N - 1][1][0]
    print " ".join(map(str, dp[N - 1][1][1]))
    
0