結果

問題 No.1433 Two color sequence
コンテスト
ユーザー 👑 terry_u16
提出日時 2021-03-19 22:15:20
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 90 ms / 2,000 ms
+ 737µs
コード長 385 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 64,368 KB
実行使用メモリ 89,516 KB
最終ジャッジ日時 2026-10-29 01:26:56
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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