結果

問題 No.193 筒の数式
ユーザー gemmarogemmaro
提出日時 2020-05-07 09:12:39
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 394 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-09-16 07:44:19
合計ジャッジ時間 2,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,292 KB
testcase_01 AC 80 ms
15,152 KB
testcase_02 AC 80 ms
15,096 KB
testcase_03 AC 79 ms
15,044 KB
testcase_04 AC 78 ms
15,296 KB
testcase_05 AC 78 ms
14,988 KB
testcase_06 AC 79 ms
15,052 KB
testcase_07 AC 78 ms
15,104 KB
testcase_08 AC 78 ms
15,160 KB
testcase_09 AC 78 ms
15,188 KB
testcase_10 AC 79 ms
15,092 KB
testcase_11 AC 80 ms
15,108 KB
testcase_12 AC 80 ms
15,156 KB
testcase_13 AC 81 ms
15,048 KB
testcase_14 AC 78 ms
15,140 KB
testcase_15 AC 77 ms
15,060 KB
testcase_16 AC 77 ms
15,024 KB
testcase_17 AC 79 ms
15,160 KB
testcase_18 AC 81 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  (0..(S.size - 1)).map do |i|
    s = S.chars.rotate(i).join
    # rubocop:todo Security/Eval
    s.stem? ? [(eval s.gsub(/0+(\d+)/) { Regexp.last_match(1) })] : []
    # rubocop:enable Security/Eval
  end.reduce(:+).max
end

class String # rubocop:todo Style/Documentation
  def stem?
    match?(/^[^+-].*[^+-]$/)
  end
end

S = gets.chomp

puts solve
0