結果

問題 No.1433 Two color sequence
ユーザー googol_S0googol_S0
提出日時 2021-03-19 22:15:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 120,392 KB
最終ジャッジ日時 2024-04-29 17:14:42
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 100 ms
109,824 KB
testcase_04 AC 99 ms
109,952 KB
testcase_05 AC 35 ms
52,096 KB
testcase_06 AC 35 ms
52,352 KB
testcase_07 AC 35 ms
52,096 KB
testcase_08 AC 108 ms
102,332 KB
testcase_09 AC 136 ms
119,788 KB
testcase_10 AC 113 ms
102,144 KB
testcase_11 AC 116 ms
101,932 KB
testcase_12 AC 139 ms
119,248 KB
testcase_13 AC 112 ms
102,396 KB
testcase_14 AC 137 ms
120,020 KB
testcase_15 AC 106 ms
102,352 KB
testcase_16 AC 106 ms
102,716 KB
testcase_17 AC 138 ms
119,992 KB
testcase_18 AC 140 ms
119,876 KB
testcase_19 AC 137 ms
120,392 KB
testcase_20 AC 109 ms
102,612 KB
testcase_21 AC 110 ms
102,344 KB
testcase_22 AC 109 ms
102,476 KB
testcase_23 AC 111 ms
102,844 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