結果

問題 No.1433 Two color sequence
ユーザー googol_S0googol_S0
提出日時 2021-03-19 22:15:59
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 123,524 KB
最終ジャッジ日時 2023-08-12 02:36:39
合計ジャッジ時間 5,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,572 KB
testcase_01 AC 70 ms
71,352 KB
testcase_02 AC 69 ms
71,320 KB
testcase_03 AC 126 ms
109,428 KB
testcase_04 AC 126 ms
109,280 KB
testcase_05 AC 69 ms
71,188 KB
testcase_06 AC 67 ms
71,220 KB
testcase_07 AC 68 ms
71,516 KB
testcase_08 AC 136 ms
106,416 KB
testcase_09 AC 172 ms
122,788 KB
testcase_10 AC 169 ms
120,028 KB
testcase_11 AC 170 ms
119,904 KB
testcase_12 AC 169 ms
122,808 KB
testcase_13 AC 169 ms
122,960 KB
testcase_14 AC 171 ms
121,912 KB
testcase_15 AC 168 ms
123,524 KB
testcase_16 AC 169 ms
123,148 KB
testcase_17 AC 173 ms
121,852 KB
testcase_18 AC 170 ms
121,908 KB
testcase_19 AC 169 ms
121,820 KB
testcase_20 AC 168 ms
123,212 KB
testcase_21 AC 168 ms
123,212 KB
testcase_22 AC 166 ms
123,188 KB
testcase_23 AC 171 ms
123,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
A=list(map(int,input().split()))
for i in range(N):
  if S[i]=='B':
    A[i]*=-1
DP=[[0,0] for i in range(N+1)]
for i in range(N):
  DP[i+1][0]=min(DP[i][0]+A[i],A[i])
  DP[i+1][1]=max(DP[i][1]+A[i],A[i])
print(max([max(-DP[i][0],DP[i][1]) for i in range(N+1)]))
0