結果

問題 No.1433 Two color sequence
ユーザー roarisroaris
提出日時 2021-03-19 21:53:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 101,764 KB
最終ジャッジ日時 2024-04-29 16:40:23
合計ジャッジ時間 4,022 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,120 KB
testcase_01 AC 51 ms
53,760 KB
testcase_02 AC 46 ms
53,376 KB
testcase_03 AC 94 ms
100,224 KB
testcase_04 AC 95 ms
100,480 KB
testcase_05 AC 46 ms
53,248 KB
testcase_06 AC 46 ms
53,504 KB
testcase_07 AC 45 ms
53,376 KB
testcase_08 AC 117 ms
101,764 KB
testcase_09 AC 129 ms
101,076 KB
testcase_10 AC 127 ms
98,416 KB
testcase_11 AC 128 ms
98,856 KB
testcase_12 AC 125 ms
100,628 KB
testcase_13 AC 126 ms
100,564 KB
testcase_14 AC 127 ms
100,428 KB
testcase_15 AC 124 ms
100,432 KB
testcase_16 AC 125 ms
100,556 KB
testcase_17 AC 126 ms
100,552 KB
testcase_18 AC 127 ms
100,804 KB
testcase_19 AC 127 ms
100,564 KB
testcase_20 AC 124 ms
100,564 KB
testcase_21 AC 126 ms
100,812 KB
testcase_22 AC 128 ms
101,196 KB
testcase_23 AC 123 ms
100,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0