結果

問題 No.1433 Two color sequence
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-20 14:13:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,544 KB
実行使用メモリ 104,392 KB
最終ジャッジ日時 2024-05-01 00:31:42
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,036 KB
testcase_01 AC 38 ms
52,068 KB
testcase_02 AC 40 ms
52,588 KB
testcase_03 AC 93 ms
104,392 KB
testcase_04 AC 87 ms
104,376 KB
testcase_05 AC 38 ms
52,992 KB
testcase_06 AC 38 ms
52,128 KB
testcase_07 AC 38 ms
53,408 KB
testcase_08 AC 104 ms
100,700 KB
testcase_09 AC 119 ms
100,020 KB
testcase_10 AC 116 ms
102,064 KB
testcase_11 AC 115 ms
102,324 KB
testcase_12 AC 116 ms
100,052 KB
testcase_13 AC 116 ms
100,668 KB
testcase_14 AC 116 ms
100,324 KB
testcase_15 AC 114 ms
100,380 KB
testcase_16 AC 114 ms
100,324 KB
testcase_17 AC 117 ms
100,056 KB
testcase_18 AC 115 ms
100,548 KB
testcase_19 AC 118 ms
100,544 KB
testcase_20 AC 113 ms
100,272 KB
testcase_21 AC 117 ms
100,004 KB
testcase_22 AC 117 ms
100,060 KB
testcase_23 AC 113 ms
100,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
A = list(map(int,input().split()))
ans = 0
mi = 0
ma = 0
count = 0
for s,a in zip(S,A):
    if s == "R":
        count += a
    else:
        count -= a
    ans = max(ans,abs(count-mi))
    ans = max(ans,abs(count-ma))
    mi = min(mi,count)
    ma = max(ma,count)
print(ans)
0