結果
| 問題 | No.1433 Two color sequence |
| コンテスト | |
| ユーザー |
あかりき
|
| 提出日時 | 2021-03-20 01:47:53 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 380 bytes |
| 記録 | |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 171,896 KB |
| 最終ジャッジ日時 | 2026-05-13 13:46:17 |
| 合計ジャッジ時間 | 3,559 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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))
あかりき