結果

問題 No.1433 Two color sequence
ユーザー kept1994kept1994
提出日時 2021-08-29 01:19:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 156,788 KB
最終ジャッジ日時 2024-05-01 19:13:12
合計ジャッジ時間 4,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,312 KB
testcase_01 AC 41 ms
53,440 KB
testcase_02 AC 39 ms
53,372 KB
testcase_03 AC 134 ms
132,292 KB
testcase_04 AC 122 ms
132,276 KB
testcase_05 AC 37 ms
52,160 KB
testcase_06 AC 39 ms
52,400 KB
testcase_07 AC 38 ms
52,828 KB
testcase_08 AC 149 ms
156,072 KB
testcase_09 AC 154 ms
156,420 KB
testcase_10 AC 152 ms
155,548 KB
testcase_11 AC 155 ms
155,804 KB
testcase_12 AC 156 ms
155,948 KB
testcase_13 AC 168 ms
155,684 KB
testcase_14 AC 155 ms
156,540 KB
testcase_15 AC 157 ms
156,284 KB
testcase_16 AC 160 ms
156,788 KB
testcase_17 AC 155 ms
156,532 KB
testcase_18 AC 157 ms
156,024 KB
testcase_19 AC 153 ms
156,004 KB
testcase_20 AC 154 ms
156,148 KB
testcase_21 AC 154 ms
156,232 KB
testcase_22 AC 153 ms
156,660 KB
testcase_23 AC 160 ms
156,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys

def main():
    import itertools 
    N = int(input())
    S = input()
    A = list(map(int, input().split()))
    RmB = []
    mRB = []
    for i in range(N):
        if S[i] == "B":
            RmB.append(-A[i])
            mRB.append(A[i])
        else:
            RmB.append(A[i])
            mRB.append(-A[i])
    sRmB = [0] + list(itertools.accumulate(RmB))
    smRB = [0] + list(itertools.accumulate(mRB))
    print(max(abs(max(sRmB) - min(sRmB)), abs(max(smRB) - min(smRB))))
    return

if __name__ == '__main__':
    main()
0