結果

問題 No.1433 Two color sequence
ユーザー shotoyooshotoyoo
提出日時 2021-03-19 21:52:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 130,464 KB
最終ジャッジ日時 2023-08-12 01:56:42
合計ジャッジ時間 5,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,232 KB
testcase_01 AC 70 ms
71,064 KB
testcase_02 AC 75 ms
71,264 KB
testcase_03 AC 137 ms
107,192 KB
testcase_04 AC 121 ms
107,384 KB
testcase_05 AC 70 ms
71,232 KB
testcase_06 AC 67 ms
71,412 KB
testcase_07 AC 69 ms
71,412 KB
testcase_08 AC 138 ms
130,464 KB
testcase_09 AC 158 ms
129,724 KB
testcase_10 AC 155 ms
127,412 KB
testcase_11 AC 152 ms
127,184 KB
testcase_12 AC 153 ms
129,692 KB
testcase_13 AC 154 ms
129,456 KB
testcase_14 AC 151 ms
129,292 KB
testcase_15 AC 151 ms
129,580 KB
testcase_16 AC 151 ms
129,384 KB
testcase_17 AC 155 ms
129,376 KB
testcase_18 AC 151 ms
129,452 KB
testcase_19 AC 156 ms
129,324 KB
testcase_20 AC 150 ms
129,196 KB
testcase_21 AC 152 ms
129,468 KB
testcase_22 AC 152 ms
129,348 KB
testcase_23 AC 150 ms
129,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")

n = int(input())
s = input()
a = list(map(int, input().split()))
dp0 = [0]
dp1 = [0]
ans = -float("inf")
for i in range(n):
    v0 = max(dp0[-1], 0)
    v1 = max(dp1[-1], 0)
    v = a[i]
    if s[i]=="R":
        v0 += v
        v1 -= v
    else:
        v0 -= v
        v1 += v
    dp0.append(v0)
    dp1.append(v1)
    ans=max(ans,v0,v1)
print(ans)
0