結果

問題 No.1433 Two color sequence
ユーザー 👑 terry_u16terry_u16
提出日時 2021-03-19 22:15:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 101,760 KB
最終ジャッジ日時 2024-04-29 17:13:44
合計ジャッジ時間 3,953 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,712 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 96 ms
100,224 KB
testcase_04 AC 93 ms
99,456 KB
testcase_05 AC 42 ms
52,096 KB
testcase_06 AC 42 ms
51,456 KB
testcase_07 AC 41 ms
51,456 KB
testcase_08 AC 117 ms
100,480 KB
testcase_09 AC 132 ms
100,096 KB
testcase_10 AC 130 ms
101,760 KB
testcase_11 AC 132 ms
101,632 KB
testcase_12 AC 134 ms
100,224 KB
testcase_13 AC 133 ms
99,712 KB
testcase_14 AC 129 ms
99,840 KB
testcase_15 AC 125 ms
99,840 KB
testcase_16 AC 124 ms
99,584 KB
testcase_17 AC 130 ms
99,712 KB
testcase_18 AC 128 ms
99,584 KB
testcase_19 AC 129 ms
99,840 KB
testcase_20 AC 126 ms
100,096 KB
testcase_21 AC 130 ms
99,840 KB
testcase_22 AC 129 ms
99,840 KB
testcase_23 AC 127 ms
99,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
a = list(map(int, input().split()))

max_score = 0

for sign_r in range(-1, 2, 2):
    sign_b = -sign_r
    score = 0
    for i in range(0, n):
        if s[i] == 'R':
            score += sign_r * a[i]
        else:
            score += sign_b * a[i]
        max_score = max(max_score, score)

        if score < 0:
            score = 0

print(max_score)
0