結果
| 問題 |
No.1433 Two color sequence
|
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2021-03-19 21:54:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 332 bytes |
| コンパイル時間 | 492 ms |
| コンパイル使用メモリ | 82,192 KB |
| 実行使用メモリ | 116,560 KB |
| 最終ジャッジ日時 | 2024-11-18 22:06:59 |
| 合計ジャッジ時間 | 4,374 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
N=int(input())
S=input()
A=list(map(int,input().split()))
T=[0]
for s,a in zip(S,A):
if s=="R":
T.append(T[-1]+a)
else:
T.append(T[-1]-a)
U=T.copy()
V=T.copy()
for i in range(1,N+1):
U[i]=min(U[i-1],U[i])
V[i]=max(V[i-1],V[i])
X=0
for i in range(1,N+1):
X=max(X,T[i]-U[i],V[i]-T[i])
print(X)
Kazun