結果

問題 No.2035 Tunnel
ユーザー maguroflymagurofly
提出日時 2023-02-28 22:11:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 261 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 11,180 KB
実行使用メモリ 18,536 KB
最終ジャッジ日時 2023-10-14 04:37:28
合計ジャッジ時間 6,873 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,252 KB
testcase_01 AC 80 ms
15,092 KB
testcase_02 AC 81 ms
15,320 KB
testcase_03 AC 81 ms
15,052 KB
testcase_04 AC 82 ms
15,252 KB
testcase_05 AC 186 ms
18,344 KB
testcase_06 AC 190 ms
18,412 KB
testcase_07 AC 188 ms
18,536 KB
testcase_08 AC 221 ms
18,380 KB
testcase_09 AC 177 ms
18,320 KB
testcase_10 AC 190 ms
18,344 KB
testcase_11 AC 164 ms
17,744 KB
testcase_12 AC 180 ms
18,392 KB
testcase_13 AC 93 ms
15,600 KB
testcase_14 AC 109 ms
16,196 KB
testcase_15 AC 170 ms
17,984 KB
testcase_16 AC 149 ms
17,328 KB
testcase_17 AC 87 ms
15,096 KB
testcase_18 AC 96 ms
15,508 KB
testcase_19 AC 119 ms
16,284 KB
testcase_20 AC 167 ms
17,800 KB
testcase_21 AC 123 ms
16,632 KB
testcase_22 AC 125 ms
16,648 KB
testcase_23 AC 101 ms
15,780 KB
testcase_24 AC 137 ms
16,900 KB
testcase_25 AC 153 ms
17,612 KB
testcase_26 AC 146 ms
17,324 KB
testcase_27 AC 179 ms
18,216 KB
testcase_28 AC 125 ms
16,644 KB
testcase_29 AC 100 ms
16,124 KB
testcase_30 AC 98 ms
15,524 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp

if S.each_char.all?(?.)
    puts 0
    exit
end

last = -2
(0 ... N).reverse_each do |i|
    c = S[i]
    next if c == ?.
    d = N - i - 1
    
    if last + 1 >= d
        d = last + 2
    end
    
    last = d
end

puts last + 1
0