結果

問題 No.1433 Two color sequence
ユーザー NoneNone
提出日時 2021-03-26 06:29:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 130,344 KB
最終ジャッジ日時 2023-08-18 11:39:42
合計ジャッジ時間 5,329 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,584 KB
testcase_01 AC 65 ms
71,472 KB
testcase_02 AC 67 ms
71,516 KB
testcase_03 AC 132 ms
118,344 KB
testcase_04 AC 126 ms
118,632 KB
testcase_05 AC 69 ms
71,148 KB
testcase_06 AC 66 ms
71,116 KB
testcase_07 AC 70 ms
71,104 KB
testcase_08 AC 149 ms
130,344 KB
testcase_09 AC 154 ms
129,424 KB
testcase_10 AC 157 ms
127,004 KB
testcase_11 AC 154 ms
127,224 KB
testcase_12 AC 157 ms
128,980 KB
testcase_13 AC 156 ms
129,368 KB
testcase_14 AC 153 ms
129,252 KB
testcase_15 AC 152 ms
129,288 KB
testcase_16 AC 153 ms
129,400 KB
testcase_17 AC 157 ms
129,372 KB
testcase_18 AC 154 ms
129,100 KB
testcase_19 AC 155 ms
129,312 KB
testcase_20 AC 153 ms
129,204 KB
testcase_21 AC 150 ms
129,156 KB
testcase_22 AC 152 ms
129,236 KB
testcase_23 AC 157 ms
129,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input().rstrip()
A=list(map(int, input().split()))
B=[]
for i in range(N):
    if S[i]=="R":
        B.append(A[i])
    else:
        B.append(-A[i])

S=[0]
for b in B:
    S.append(S[-1]+b)

m,M=0,0


res=0

for s in S:
    if s>=0:
        res=max(s-m,res)
    else:
        res=max(M-s,res)
    m=min(s,m)
    M=max(s,M)

print(res)
0