結果

問題 No.1433 Two color sequence
コンテスト
ユーザー 👑 rin204
提出日時 2021-12-13 01:51:40
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 84 ms / 2,000 ms
+ 54µs
コード長 288 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 92 ms
コンパイル使用メモリ 64,548 KB
実行使用メモリ 89,512 KB
最終ジャッジ日時 2026-10-29 02:05:11
合計ジャッジ時間 5,023 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
S = input()
A = list(map(int, input().split()))
for i in range(n):
    if S[i] == "R":
        A[i] *= -1

tot = 0
max_ = 0
min_ = 0
ans = 0
for a in A:
    tot += a
    min_ = min(min_, tot)
    max_ = max(max_, tot)
    ans = max(ans, max_ - tot, tot - min_)
print(ans)
0