結果
問題 | No.1433 Two color sequence |
ユーザー |
|
提出日時 | 2021-03-19 21:53:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 356 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,268 KB |
実行使用メモリ | 102,012 KB |
最終ジャッジ日時 | 2024-11-18 22:02:15 |
合計ジャッジ時間 | 3,801 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import sys input = sys.stdin.readline from collections import * N = int(input()) S = input()[:-1] a = list(map(int, input().split())) m, M = 0, 0 now = 0 ans = -10**18 for i in range(N): if S[i]=='R': now += a[i] else: now -= a[i] ans = max(ans, abs(now-m), abs(M-now)) m = min(m, now) M = max(M, now) print(ans)