結果

問題 No.1433 Two color sequence
ユーザー lloyzlloyz
提出日時 2022-01-25 23:01:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,568 KB
実行使用メモリ 32,336 KB
最終ジャッジ日時 2023-08-22 18:36:57
合計ジャッジ時間 10,970 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 16 ms
7,708 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 394 ms
11,776 KB
testcase_04 AC 381 ms
11,760 KB
testcase_05 AC 16 ms
7,768 KB
testcase_06 AC 15 ms
7,780 KB
testcase_07 AC 15 ms
7,856 KB
testcase_08 AC 426 ms
32,336 KB
testcase_09 AC 441 ms
30,440 KB
testcase_10 AC 425 ms
29,164 KB
testcase_11 AC 420 ms
29,168 KB
testcase_12 AC 424 ms
29,920 KB
testcase_13 AC 438 ms
29,956 KB
testcase_14 AC 448 ms
29,984 KB
testcase_15 AC 453 ms
30,056 KB
testcase_16 AC 458 ms
30,044 KB
testcase_17 AC 446 ms
30,032 KB
testcase_18 AC 448 ms
29,976 KB
testcase_19 AC 443 ms
30,100 KB
testcase_20 AC 438 ms
30,648 KB
testcase_21 AC 448 ms
30,108 KB
testcase_22 AC 452 ms
30,036 KB
testcase_23 AC 449 ms
30,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
A = list(map(int, input().split()))

minv = 0
maxv = 0
v = 0
ans = 0
for i in range(n):
    if S[i] == 'R':
        v += A[i]
    elif S[i] == 'B':
        v -= A[i]
    ans = max(ans, abs(v - minv))
    ans = max(ans, abs(v - maxv))
    minv = min(minv, v)
    maxv = max(maxv, v)
print(ans)
0