結果

問題 No.1433 Two color sequence
ユーザー U SU S
提出日時 2021-03-20 03:29:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 146,896 KB
最終ジャッジ日時 2024-04-29 23:02:10
合計ジャッジ時間 4,556 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
60,544 KB
testcase_01 AC 52 ms
60,544 KB
testcase_02 AC 51 ms
60,288 KB
testcase_03 AC 123 ms
120,608 KB
testcase_04 AC 134 ms
120,548 KB
testcase_05 AC 47 ms
60,032 KB
testcase_06 AC 46 ms
60,416 KB
testcase_07 AC 47 ms
60,160 KB
testcase_08 AC 143 ms
146,896 KB
testcase_09 AC 156 ms
146,292 KB
testcase_10 AC 151 ms
145,564 KB
testcase_11 AC 157 ms
145,432 KB
testcase_12 AC 161 ms
146,812 KB
testcase_13 AC 158 ms
146,812 KB
testcase_14 AC 155 ms
146,548 KB
testcase_15 AC 159 ms
146,536 KB
testcase_16 AC 158 ms
146,400 KB
testcase_17 AC 158 ms
146,540 KB
testcase_18 AC 158 ms
146,400 KB
testcase_19 AC 156 ms
146,148 KB
testcase_20 AC 161 ms
146,420 KB
testcase_21 AC 157 ms
146,148 KB
testcase_22 AC 155 ms
146,152 KB
testcase_23 AC 157 ms
146,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e30)
mod = 998244353

n =int(input())
s = input()
a = lmp()
for i in range(n):
    if s[i] == "B":a[i]*=-1
a = [0] + list(accumulate(a))
mx = list(accumulate(a, func=max))
mn = list(accumulate(a, func=min))
print(mx[-1]-mn[-1])







0