結果

問題 No.193 筒の数式
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-22 13:50:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 612 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 11,316 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-10-11 18:13:14
合計ジャッジ時間 2,857 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,312 KB
testcase_01 AC 79 ms
15,124 KB
testcase_02 AC 78 ms
15,052 KB
testcase_03 AC 77 ms
15,060 KB
testcase_04 AC 78 ms
15,080 KB
testcase_05 AC 81 ms
15,304 KB
testcase_06 AC 78 ms
15,120 KB
testcase_07 AC 78 ms
15,272 KB
testcase_08 AC 77 ms
15,300 KB
testcase_09 AC 79 ms
15,060 KB
testcase_10 AC 78 ms
15,224 KB
testcase_11 AC 78 ms
15,044 KB
testcase_12 AC 79 ms
15,108 KB
testcase_13 AC 77 ms
15,116 KB
testcase_14 AC 78 ms
15,000 KB
testcase_15 AC 78 ms
15,116 KB
testcase_16 AC 78 ms
15,332 KB
testcase_17 AC 78 ms
15,180 KB
testcase_18 AC 78 ms
15,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

expr = gets.strip
len = expr.length
max = 10 ** 10 * -1
len.times do |i|
    next if expr[i] == "+" || expr[i] == "-"
    next if expr[(i + len - 1) % len] == "+" || expr[(i + len - 1) % len] == "-"
    k = 0
    substr = ""
    sum = 0
    while true do 
        while k < len do
            c = (i + k) % len
            break if expr[c] == "+" || expr[c] == "-"
            k += 1
            substr += expr[c]
        end
        sum += substr.to_i
        break if k >= len
        c = (i + k) % len
        substr = expr[c]
        k += 1
    end
    if sum > max
        max = sum
    end    
end
puts max
0