結果

問題 No.1433 Two color sequence
ユーザー mesame3993mesame3993
提出日時 2021-12-09 00:59:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 1,672 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 104,564 KB
最終ジャッジ日時 2023-09-23 12:17:41
合計ジャッジ時間 6,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,124 KB
testcase_01 AC 66 ms
71,344 KB
testcase_02 AC 68 ms
71,604 KB
testcase_03 AC 109 ms
104,348 KB
testcase_04 AC 109 ms
104,564 KB
testcase_05 AC 69 ms
71,440 KB
testcase_06 AC 70 ms
71,128 KB
testcase_07 AC 71 ms
71,392 KB
testcase_08 AC 126 ms
102,972 KB
testcase_09 AC 134 ms
101,968 KB
testcase_10 AC 128 ms
99,932 KB
testcase_11 AC 130 ms
99,736 KB
testcase_12 AC 130 ms
102,076 KB
testcase_13 AC 130 ms
102,064 KB
testcase_14 AC 129 ms
101,908 KB
testcase_15 AC 127 ms
101,796 KB
testcase_16 AC 126 ms
102,024 KB
testcase_17 AC 132 ms
101,912 KB
testcase_18 AC 130 ms
101,816 KB
testcase_19 AC 134 ms
102,012 KB
testcase_20 AC 128 ms
102,028 KB
testcase_21 AC 133 ms
102,052 KB
testcase_22 AC 132 ms
102,028 KB
testcase_23 AC 134 ms
101,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin
  readline = stdin.readline
  n= int(readline())
  s = readline()[:-1]
  A = list(map(int, readline().split()))
  now = 0
  ans = 0
  maxv, minv = 0, 0
  for i in range(n):
    if s[i] == 'B':
      A[i] *= -1
  for i in range(n):
    now += A[i]
    ans = max(ans, abs(now - minv))
    ans = max(ans, abs(now - maxv))
    minv = min(minv, now)
    maxv = max(maxv, now)
  print(ans)
  
if __name__ == "__main__":
  main() 
0