結果
| 問題 |
No.1433 Two color sequence
|
| コンテスト | |
| ユーザー |
あかりき
|
| 提出日時 | 2021-03-20 01:47:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 164 ms / 2,000 ms |
| コード長 | 380 bytes |
| コンパイル時間 | 458 ms |
| コンパイル使用メモリ | 82,344 KB |
| 実行使用メモリ | 171,384 KB |
| 最終ジャッジ日時 | 2024-11-19 05:34:00 |
| 合計ジャッジ時間 | 5,085 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
n=int(input())
s=list(input())
a=list(map(int,input().split()))
L1=[]
L2=[]
for i in range(n):
if s[i]=='R':
L1.append(a[i])
L2.append(-a[i])
else:
L1.append(-a[i])
L2.append(a[i])
ans1=[]
ans2=[]
ct1=0
ct2=0
for i in range(n):
ct1+=L1[i]
if ct1<0:
ct1=0
ans1.append(ct1)
ct2+=L2[i]
if ct2<0:
ct2=0
ans2.append(ct2)
print(max(ans1+ans2))
あかりき