結果

問題 No.1433 Two color sequence
ユーザー FromBooskaFromBooska
提出日時 2023-03-02 08:04:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 128,812 KB
最終ジャッジ日時 2023-10-17 06:25:51
合計ジャッジ時間 6,339 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,440 KB
testcase_01 AC 39 ms
53,440 KB
testcase_02 AC 38 ms
53,440 KB
testcase_03 AC 105 ms
128,812 KB
testcase_04 AC 100 ms
128,768 KB
testcase_05 AC 38 ms
53,440 KB
testcase_06 AC 37 ms
53,440 KB
testcase_07 AC 38 ms
53,440 KB
testcase_08 AC 122 ms
126,196 KB
testcase_09 AC 127 ms
126,240 KB
testcase_10 AC 125 ms
125,456 KB
testcase_11 AC 124 ms
125,628 KB
testcase_12 AC 127 ms
126,232 KB
testcase_13 AC 128 ms
126,240 KB
testcase_14 AC 126 ms
126,396 KB
testcase_15 AC 126 ms
126,388 KB
testcase_16 AC 125 ms
126,388 KB
testcase_17 AC 125 ms
126,336 KB
testcase_18 AC 125 ms
126,308 KB
testcase_19 AC 125 ms
126,396 KB
testcase_20 AC 127 ms
126,400 KB
testcase_21 AC 126 ms
126,392 KB
testcase_22 AC 127 ms
126,392 KB
testcase_23 AC 126 ms
126,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 青の得点は正負符号を逆転する
# 累積和、最初は0スタート
# この最大値と最小値の差が答えでいいか

N = int(input())
S = input()
A = list(map(int, input().split()))
A_use = []
for i in range(N):
    if S[i] == 'R':
        A_use.append(A[i])
    else:
        A_use.append(-A[i])

cum = [0]
temp = 0
for i in range(N):
    temp += A_use[i]
    cum.append(temp)
    
ans = max(cum)-min(cum)
print(ans)    
0