結果

問題 No.996 Phnom Penh
ユーザー HaarHaar
提出日時 2020-02-21 23:51:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 511 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-04-17 09:37:41
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,160 KB
testcase_01 AC 83 ms
12,160 KB
testcase_02 AC 85 ms
12,288 KB
testcase_03 AC 84 ms
12,288 KB
testcase_04 AC 86 ms
12,160 KB
testcase_05 AC 84 ms
12,032 KB
testcase_06 AC 90 ms
12,288 KB
testcase_07 AC 84 ms
12,160 KB
testcase_08 AC 87 ms
12,160 KB
testcase_09 AC 85 ms
12,032 KB
testcase_10 AC 84 ms
11,904 KB
testcase_11 AC 84 ms
12,160 KB
testcase_12 AC 86 ms
12,288 KB
testcase_13 AC 136 ms
14,080 KB
testcase_14 AC 137 ms
14,208 KB
testcase_15 AC 137 ms
14,208 KB
testcase_16 AC 139 ms
14,208 KB
testcase_17 AC 138 ms
14,336 KB
testcase_18 AC 85 ms
12,160 KB
testcase_19 AC 86 ms
12,288 KB
testcase_20 AC 85 ms
12,288 KB
testcase_21 AC 84 ms
12,032 KB
testcase_22 AC 84 ms
12,288 KB
testcase_23 AC 84 ms
12,160 KB
testcase_24 AC 171 ms
17,792 KB
testcase_25 AC 196 ms
14,592 KB
testcase_26 AC 205 ms
14,660 KB
testcase_27 AC 179 ms
14,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$s = STDIN.gets

$ans = 0


def f
  temp = 0
  
  $s.scan(/phnom/).each do |t|
    temp += 1
  end

  if $s.include?("phnom") then
    $s.gsub!(/phnom/, "penh")
  end

  if $s.include?("h") or $s.include?("e") then
    temp += 1
    $s.gsub!(/h/, "")
    $s.gsub!(/e/, "h")
  end
  
#  puts $s
  
  temp
end


$ans += f
$ans += f



$s.scan(/phn(?:om)+/).each do |t|
  $ans += t.length - 3
end

if $s.include?("phnom") then
  $ans += 1
elsif $s.include?("h") or $s.include?("e")then
  $ans += 1
end


puts $ans
0