結果

問題 No.1433 Two color sequence
ユーザー Suu0313Suu0313
提出日時 2021-03-20 13:59:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 424 ms / 2,000 ms
コード長 301 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,580 KB
最終ジャッジ日時 2024-05-01 00:19:30
合計ジャッジ時間 8,950 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 338 ms
14,600 KB
testcase_04 AC 329 ms
14,548 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 385 ms
33,580 KB
testcase_09 AC 395 ms
32,604 KB
testcase_10 AC 384 ms
31,900 KB
testcase_11 AC 380 ms
31,788 KB
testcase_12 AC 413 ms
32,592 KB
testcase_13 AC 406 ms
32,472 KB
testcase_14 AC 396 ms
32,852 KB
testcase_15 AC 393 ms
32,856 KB
testcase_16 AC 399 ms
32,984 KB
testcase_17 AC 397 ms
32,852 KB
testcase_18 AC 394 ms
32,856 KB
testcase_19 AC 411 ms
32,852 KB
testcase_20 AC 406 ms
33,316 KB
testcase_21 AC 424 ms
32,872 KB
testcase_22 AC 397 ms
32,856 KB
testcase_23 AC 397 ms
32,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
a = list(map(int, input().split()))
ans = 0
r = 0
b = 0

for i in range(n):
    if s[i] == 'R':
        r = max(a[i], r + a[i])
        b = max(-a[i], b - a[i])
    else:
        r = max(-a[i], r - a[i])
        b = max(a[i], b + a[i])
    ans = max(ans, r, b)

print(ans)
0