結果

問題 No.1433 Two color sequence
ユーザー tyawanmusityawanmusi
提出日時 2020-12-15 19:27:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 420 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 32,728 KB
最終ジャッジ日時 2023-10-20 09:44:24
合計ジャッジ時間 8,788 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,056 KB
testcase_01 AC 30 ms
10,056 KB
testcase_02 AC 29 ms
10,056 KB
testcase_03 AC 361 ms
13,448 KB
testcase_04 AC 359 ms
13,448 KB
testcase_05 AC 28 ms
10,056 KB
testcase_06 AC 30 ms
10,056 KB
testcase_07 AC 28 ms
10,056 KB
testcase_08 AC 405 ms
32,728 KB
testcase_09 AC 406 ms
32,324 KB
testcase_10 AC 400 ms
31,056 KB
testcase_11 AC 393 ms
31,180 KB
testcase_12 AC 411 ms
31,880 KB
testcase_13 AC 419 ms
31,884 KB
testcase_14 AC 416 ms
32,000 KB
testcase_15 AC 412 ms
32,000 KB
testcase_16 AC 411 ms
32,000 KB
testcase_17 AC 419 ms
32,000 KB
testcase_18 AC 420 ms
32,000 KB
testcase_19 AC 407 ms
32,000 KB
testcase_20 AC 411 ms
32,608 KB
testcase_21 AC 407 ms
32,000 KB
testcase_22 AC 414 ms
32,000 KB
testcase_23 AC 402 ms
32,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
a = list(map(int, input().split()))
x = [0]
for i in range(n):
  if s[i] == "R":
    x.append(x[-1]+a[i])
  else:
    x.append(x[-1]-a[i])
ans=0
mi=0
ma=0
for i in range(1, n+1):
  ans = max(ans, x[i]-mi, ma-x[i])
  mi = min(x[i], mi)
  ma = max(x[i], ma)
print(ans)
0