結果

問題 No.1433 Two color sequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-20 14:13:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 103,996 KB
最終ジャッジ日時 2024-11-20 23:25:16
合計ジャッジ時間 3,622 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
A = list(map(int,input().split()))
ans = 0
mi = 0
ma = 0
count = 0
for s,a in zip(S,A):
    if s == "R":
        count += a
    else:
        count -= a
    ans = max(ans,abs(count-mi))
    ans = max(ans,abs(count-ma))
    mi = min(mi,count)
    ma = max(ma,count)
print(ans)
0