結果

問題 No.1433 Two color sequence
ユーザー 👑 rin204rin204
提出日時 2021-12-13 01:51:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 105,004 KB
最終ジャッジ日時 2023-09-28 20:40:09
合計ジャッジ時間 7,377 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,308 KB
testcase_01 AC 74 ms
71,072 KB
testcase_02 AC 76 ms
71,096 KB
testcase_03 AC 123 ms
104,860 KB
testcase_04 AC 117 ms
105,004 KB
testcase_05 AC 75 ms
71,052 KB
testcase_06 AC 74 ms
71,292 KB
testcase_07 AC 75 ms
71,148 KB
testcase_08 AC 133 ms
103,108 KB
testcase_09 AC 142 ms
101,908 KB
testcase_10 AC 144 ms
100,232 KB
testcase_11 AC 145 ms
99,916 KB
testcase_12 AC 145 ms
102,004 KB
testcase_13 AC 143 ms
101,964 KB
testcase_14 AC 141 ms
101,868 KB
testcase_15 AC 142 ms
101,820 KB
testcase_16 AC 144 ms
101,988 KB
testcase_17 AC 149 ms
101,992 KB
testcase_18 AC 144 ms
101,788 KB
testcase_19 AC 147 ms
101,872 KB
testcase_20 AC 145 ms
101,904 KB
testcase_21 AC 143 ms
101,912 KB
testcase_22 AC 144 ms
101,904 KB
testcase_23 AC 146 ms
101,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
A = list(map(int, input().split()))
for i in range(n):
    if S[i] == "R":
        A[i] *= -1

tot = 0
max_ = 0
min_ = 0
ans = 0
for a in A:
    tot += a
    min_ = min(min_, tot)
    max_ = max(max_, tot)
    ans = max(ans, max_ - tot, tot - min_)
print(ans)
0