結果

問題 No.1433 Two color sequence
ユーザー 👑 terry_u16terry_u16
提出日時 2021-03-19 22:15:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 105,152 KB
最終ジャッジ日時 2023-08-12 02:35:41
合計ジャッジ時間 5,396 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,624 KB
testcase_01 AC 69 ms
71,180 KB
testcase_02 AC 71 ms
71,276 KB
testcase_03 AC 113 ms
105,136 KB
testcase_04 AC 113 ms
105,152 KB
testcase_05 AC 71 ms
71,408 KB
testcase_06 AC 71 ms
71,436 KB
testcase_07 AC 70 ms
71,284 KB
testcase_08 AC 128 ms
103,028 KB
testcase_09 AC 146 ms
102,192 KB
testcase_10 AC 145 ms
100,448 KB
testcase_11 AC 144 ms
100,108 KB
testcase_12 AC 145 ms
102,160 KB
testcase_13 AC 142 ms
102,000 KB
testcase_14 AC 141 ms
101,932 KB
testcase_15 AC 137 ms
102,084 KB
testcase_16 AC 138 ms
102,116 KB
testcase_17 AC 143 ms
101,872 KB
testcase_18 AC 141 ms
101,856 KB
testcase_19 AC 143 ms
101,976 KB
testcase_20 AC 136 ms
102,088 KB
testcase_21 AC 140 ms
101,844 KB
testcase_22 AC 140 ms
101,844 KB
testcase_23 AC 133 ms
101,932 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