結果

問題 No.1433 Two color sequence
ユーザー kept1994kept1994
提出日時 2021-08-29 01:19:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 160,064 KB
最終ジャッジ日時 2023-08-14 06:27:59
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,408 KB
testcase_01 AC 76 ms
71,336 KB
testcase_02 AC 73 ms
71,412 KB
testcase_03 AC 169 ms
131,856 KB
testcase_04 AC 156 ms
131,864 KB
testcase_05 AC 72 ms
71,416 KB
testcase_06 AC 72 ms
71,256 KB
testcase_07 AC 73 ms
71,464 KB
testcase_08 AC 183 ms
160,064 KB
testcase_09 AC 188 ms
158,992 KB
testcase_10 AC 185 ms
156,316 KB
testcase_11 AC 184 ms
156,604 KB
testcase_12 AC 187 ms
158,892 KB
testcase_13 AC 184 ms
159,084 KB
testcase_14 AC 185 ms
158,876 KB
testcase_15 AC 183 ms
158,996 KB
testcase_16 AC 178 ms
159,008 KB
testcase_17 AC 178 ms
159,076 KB
testcase_18 AC 177 ms
159,116 KB
testcase_19 AC 178 ms
158,924 KB
testcase_20 AC 178 ms
158,852 KB
testcase_21 AC 175 ms
158,832 KB
testcase_22 AC 181 ms
159,104 KB
testcase_23 AC 175 ms
159,008 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