結果

問題 No.346 チワワ数え上げ問題
ユーザー code-devocode-devo
提出日時 2016-02-26 22:32:04
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 261 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 11,892 KB
実行使用メモリ 69,440 KB
最終ジャッジ日時 2023-10-23 20:31:06
合計ジャッジ時間 13,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
16,080 KB
testcase_01 AC 82 ms
16,080 KB
testcase_02 AC 83 ms
16,080 KB
testcase_03 AC 83 ms
16,080 KB
testcase_04 AC 82 ms
16,080 KB
testcase_05 AC 82 ms
16,080 KB
testcase_06 AC 83 ms
16,080 KB
testcase_07 AC 84 ms
16,080 KB
testcase_08 AC 83 ms
16,080 KB
testcase_09 AC 83 ms
16,080 KB
testcase_10 AC 1,068 ms
69,440 KB
testcase_11 AC 439 ms
44,284 KB
testcase_12 AC 692 ms
54,096 KB
testcase_13 AC 350 ms
29,724 KB
testcase_14 AC 86 ms
16,088 KB
testcase_15 AC 626 ms
35,468 KB
testcase_16 AC 797 ms
57,264 KB
testcase_17 AC 1,068 ms
69,196 KB
testcase_18 AC 1,043 ms
68,912 KB
testcase_19 AC 845 ms
62,284 KB
testcase_20 AC 156 ms
17,248 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = gets.chomp

h = Hash.new{|s,k| s[k] = []}

for i in 0..(s.length-1) do
  case s[i]
  when "c" then h["c"] << i
  when "w" then h["w"] << i
  end
end

count = 0
h["c"].each do |i|
  ws = h["w"].select{|j| j > i}.size
  count += ws * (ws-1) / 2
end
puts count
0