結果

問題 No.1433 Two color sequence
ユーザー O2MTO2MT
提出日時 2021-03-20 18:31:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 117,760 KB
最終ジャッジ日時 2024-05-01 05:44:21
合計ジャッジ時間 3,654 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,352 KB
testcase_01 AC 34 ms
52,096 KB
testcase_02 AC 33 ms
52,224 KB
testcase_03 AC 86 ms
117,480 KB
testcase_04 AC 83 ms
117,760 KB
testcase_05 AC 32 ms
52,272 KB
testcase_06 AC 32 ms
52,096 KB
testcase_07 AC 32 ms
52,352 KB
testcase_08 AC 99 ms
113,080 KB
testcase_09 AC 106 ms
112,496 KB
testcase_10 AC 108 ms
112,252 KB
testcase_11 AC 103 ms
112,192 KB
testcase_12 AC 107 ms
112,500 KB
testcase_13 AC 107 ms
112,496 KB
testcase_14 AC 104 ms
112,704 KB
testcase_15 AC 103 ms
112,720 KB
testcase_16 AC 103 ms
112,836 KB
testcase_17 AC 106 ms
112,972 KB
testcase_18 AC 110 ms
112,840 KB
testcase_19 AC 108 ms
112,816 KB
testcase_20 AC 104 ms
113,236 KB
testcase_21 AC 106 ms
112,832 KB
testcase_22 AC 111 ms
112,592 KB
testcase_23 AC 113 ms
113,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N = int(input())
S = str(input())
A = list(map(int,input().split()))
for i in range(N):
    if S[i] == 'B':
        A[i] = -A[i]
AC = list(accumulate(A))

mi,ma = min(AC),max(AC)
mii,maa = mi,ma
for i in range(N):
    mi = min(mi,mii-AC[i])
    ma = max(ma,maa-AC[i])
ans = max(abs(mi),ma)
print(ans)
0