結果

問題 No.1433 Two color sequence
コンテスト
ユーザー U S
提出日時 2021-03-20 03:29:03
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 588 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 214 ms
コンパイル使用メモリ 85,152 KB
実行使用メモリ 147,160 KB
最終ジャッジ日時 2026-05-13 15:57:12
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 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