結果

問題 No.45 回転寿司
ユーザー syuki791syuki791
提出日時 2019-02-04 23:09:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-08-26 23:35:14
合計ジャッジ時間 2,837 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 16 ms
8,004 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 16 ms
7,964 KB
testcase_23 AC 17 ms
7,916 KB
testcase_24 AC 16 ms
7,832 KB
testcase_25 AC 16 ms
7,844 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 16 ms
7,892 KB
testcase_32 AC 16 ms
7,908 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.py:38: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if message is 'right':

ソースコード

diff #

def selectmax(a1,a2,a3,a4):
    left = a1 + a3
    right = a2 + a4
    edge = a1 + a4
    max1 = max(left,right,edge)
    if max1 == right:
        return 'right'
    else:
        return 'left'


n = int(input())
m = input().split()
v = [0]
sum = []
for num in range(n):
    v.append(int(m[num]))

judge = True
i = 1
num2 = n
sum = 0
while judge:
    judge = False
    if num2 == 1:
        sum += v[i]
    elif num2 == 2:
        sum += max(v[i],v[i+1])
    elif num2 == 3:
        sum += max(v[i]+v[i+2],v[i+1])
    else:
        judge = True
        b1 = v[i]
        b2 = v[i+1]
        b3 = v[i+2]
        b4 = v[i+3]
        message = selectmax(b1,b2,b3,b4)
        if message is 'right':
            sum += b2
            i += 3
            num2 -= 3
        else:
            sum += b1
            i += 2
            num2 -= 2
print(sum)
0