結果

問題 No.1433 Two color sequence
ユーザー mesame3993mesame3993
提出日時 2021-12-09 01:06:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 414 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 111,172 KB
最終ジャッジ日時 2023-09-23 12:20:53
合計ジャッジ時間 10,514 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,252 KB
testcase_01 AC 72 ms
71,140 KB
testcase_02 AC 73 ms
71,088 KB
testcase_03 AC 253 ms
104,492 KB
testcase_04 AC 238 ms
104,756 KB
testcase_05 AC 71 ms
71,500 KB
testcase_06 AC 70 ms
71,140 KB
testcase_07 AC 69 ms
71,608 KB
testcase_08 AC 293 ms
111,172 KB
testcase_09 AC 307 ms
109,448 KB
testcase_10 AC 308 ms
106,908 KB
testcase_11 AC 319 ms
107,236 KB
testcase_12 AC 315 ms
109,248 KB
testcase_13 AC 322 ms
109,080 KB
testcase_14 AC 382 ms
109,540 KB
testcase_15 AC 316 ms
109,364 KB
testcase_16 AC 367 ms
108,960 KB
testcase_17 AC 414 ms
109,500 KB
testcase_18 AC 374 ms
108,744 KB
testcase_19 AC 369 ms
109,388 KB
testcase_20 AC 331 ms
108,896 KB
testcase_21 AC 368 ms
109,288 KB
testcase_22 AC 370 ms
109,524 KB
testcase_23 AC 333 ms
109,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  import sys
  readline = sys.stdin.readline
  def error(*args, end='\n'):
    print(*args, end=end, file=sys.stderr)
  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
  error(A)
  for i in range(n):
    now += A[i]
    ans = max(ans, abs(now - minv))
    ans = max(ans, abs(now - maxv))
    error(ans, now, minv, maxv)
    minv = min(minv, now)
    maxv = max(maxv, now)
  print(ans)
  
if __name__ == "__main__":
  main() 
0