結果

問題 No.1433 Two color sequence
ユーザー roarisroaris
提出日時 2021-03-19 21:53:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 108,680 KB
最終ジャッジ日時 2023-08-12 01:58:13
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,720 KB
testcase_01 AC 90 ms
71,568 KB
testcase_02 AC 87 ms
71,672 KB
testcase_03 AC 140 ms
105,196 KB
testcase_04 AC 126 ms
105,096 KB
testcase_05 AC 85 ms
71,880 KB
testcase_06 AC 86 ms
71,688 KB
testcase_07 AC 87 ms
71,644 KB
testcase_08 AC 135 ms
108,452 KB
testcase_09 AC 152 ms
108,420 KB
testcase_10 AC 148 ms
108,168 KB
testcase_11 AC 151 ms
108,652 KB
testcase_12 AC 152 ms
108,576 KB
testcase_13 AC 152 ms
108,488 KB
testcase_14 AC 150 ms
108,356 KB
testcase_15 AC 143 ms
108,608 KB
testcase_16 AC 145 ms
108,436 KB
testcase_17 AC 148 ms
108,400 KB
testcase_18 AC 146 ms
108,408 KB
testcase_19 AC 148 ms
108,348 KB
testcase_20 AC 144 ms
108,404 KB
testcase_21 AC 148 ms
108,092 KB
testcase_22 AC 148 ms
108,020 KB
testcase_23 AC 145 ms
108,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
a = list(map(int, input().split()))
m, M = 0, 0
now = 0
ans = -10**18

for i in range(N):
    if S[i]=='R':
        now += a[i]
    else:
        now -= a[i]
    
    ans = max(ans, abs(now-m), abs(M-now))
    m = min(m, now)
    M = max(M, now)

print(ans)
0