結果

問題 No.1433 Two color sequence
ユーザー paruf4paruf4
提出日時 2021-03-20 00:54:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 42,632 KB
最終ジャッジ日時 2024-04-29 20:45:24
合計ジャッジ時間 5,588 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,624 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 188 ms
16,944 KB
testcase_04 AC 183 ms
16,824 KB
testcase_05 AC 27 ms
10,624 KB
testcase_06 AC 27 ms
10,624 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 222 ms
36,388 KB
testcase_09 AC 239 ms
42,236 KB
testcase_10 AC 231 ms
38,648 KB
testcase_11 AC 230 ms
39,900 KB
testcase_12 AC 243 ms
41,536 KB
testcase_13 AC 251 ms
42,632 KB
testcase_14 AC 245 ms
40,580 KB
testcase_15 AC 253 ms
38,616 KB
testcase_16 AC 246 ms
37,380 KB
testcase_17 AC 253 ms
40,200 KB
testcase_18 AC 240 ms
38,356 KB
testcase_19 AC 236 ms
39,940 KB
testcase_20 AC 225 ms
36,436 KB
testcase_21 AC 249 ms
41,608 KB
testcase_22 AC 247 ms
41,604 KB
testcase_23 AC 237 ms
35,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(input())
a = list(map(int, input().split()))

rb = [0]*(n+1)
br = [0]*(n+1)
sr, sb = 0, 0

for i in range(n):
    if s[i] == "R":
        sr += a[i]
    else:
        sb += a[i]
    rb[i+1] = sr-sb
    br[i+1] = sb-sr

print(max(max(rb)-min(rb), max(br)-min(br)))
0