結果

問題 No.346 チワワ数え上げ問題
ユーザー cympfhcympfh
提出日時 2016-02-29 15:10:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 113 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 23,712 KB
最終ジャッジ日時 2023-10-24 19:09:02
合計ジャッジ時間 3,878 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,120 KB
testcase_01 AC 88 ms
16,120 KB
testcase_02 AC 86 ms
16,120 KB
testcase_03 AC 87 ms
16,120 KB
testcase_04 AC 85 ms
16,120 KB
testcase_05 AC 84 ms
16,120 KB
testcase_06 AC 86 ms
16,120 KB
testcase_07 AC 88 ms
16,120 KB
testcase_08 AC 86 ms
16,120 KB
testcase_09 AC 88 ms
16,120 KB
testcase_10 AC 147 ms
23,708 KB
testcase_11 AC 119 ms
20,036 KB
testcase_12 AC 136 ms
22,564 KB
testcase_13 AC 116 ms
19,964 KB
testcase_14 AC 89 ms
16,252 KB
testcase_15 AC 133 ms
22,004 KB
testcase_16 AC 136 ms
22,692 KB
testcase_17 AC 149 ms
23,700 KB
testcase_18 AC 147 ms
23,704 KB
testcase_19 AC 139 ms
23,140 KB
testcase_20 AC 150 ms
23,712 KB
testcase_21 AC 151 ms
23,712 KB
testcase_22 AC 151 ms
23,712 KB
testcase_23 AC 85 ms
16,120 KB
testcase_24 AC 89 ms
16,120 KB
testcase_25 AC 86 ms
16,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

cs=gets.chomp.chars
y=cs.count{|c|c=='w'}
ans=0
cs.each{|c|
  y-=1 if c=='w'
  ans += y*(y-1)/2 if c=='c'
}
p ans
0