結果

問題 No.45 回転寿司
ユーザー ABKZABKZ
提出日時 2023-10-06 12:54:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 77,432 KB
最終ジャッジ日時 2023-10-06 12:54:36
合計ジャッジ時間 5,299 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 78 ms
76,332 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 73 ms
71,356 KB
testcase_23 AC 70 ms
71,620 KB
testcase_24 AC 70 ms
71,536 KB
testcase_25 AC 69 ms
71,456 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 71 ms
71,568 KB
testcase_32 AC 74 ms
71,452 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
while len(V) > V.count(0):
    if len(V) < 3:
        ans += max(V)
        break
    a = []
    for i in range(len(V)-2):
        a.append(V[i] + V[i+2])
    t = a.index(max(a))
    c0 = V[t]
    c1 = V[t+2]
    if c0 > c1:
        ans += c0
        if t > 0:
            V[t-1] = 0
        V[t] = 0
        V[t+1] = 0
    else:
        ans += c1
        if t+3 < len(V):
            V[t+3] = 0
        V[t+2] = 0
        V[t+1] = 0
print(ans)
0