結果
問題 | No.1433 Two color sequence |
ユーザー |
![]() |
提出日時 | 2021-03-21 04:10:33 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 427 ms / 2,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 114 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 32,896 KB |
最終ジャッジ日時 | 2024-11-21 18:22:37 |
合計ジャッジ時間 | 9,491 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - v Syntax OK
ソースコード
N = gets.to_iS = gets.chompA = gets.split.map(&:to_i)cur = Array.new(2) { Array.new(2, 0) }ans = -Float::INFINITYA.zip(S.chars) do |a, s|2.times do |i|r, b = cur[i]v = (r - b).absnr = (s == 'R') ? r + a : rnb = (s == 'B') ? b + a : bnv = (nr - nb).absans = nv if ans < nvif i == 0if nr >= nbcur[i] = [nr, nb]elsecur[i] = [0, 0]endelseif nr <= nbcur[i] = [nr, nb]elsecur[i] = [0, 0]endendendendputs ans