結果

問題 No.346 チワワ数え上げ問題
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-02-27 17:39:14
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 9,352 ms
コンパイル使用メモリ 243,768 KB
実行使用メモリ 62,424 KB
最終ジャッジ日時 2024-06-29 13:09:38
合計ジャッジ時間 33,393 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 880 ms
62,300 KB
testcase_01 AC 881 ms
62,348 KB
testcase_02 AC 913 ms
62,308 KB
testcase_03 AC 881 ms
62,372 KB
testcase_04 AC 897 ms
62,300 KB
testcase_05 AC 877 ms
62,160 KB
testcase_06 AC 884 ms
62,308 KB
testcase_07 AC 886 ms
62,352 KB
testcase_08 AC 862 ms
62,276 KB
testcase_09 AC 883 ms
62,272 KB
testcase_10 WA -
testcase_11 AC 895 ms
62,168 KB
testcase_12 WA -
testcase_13 AC 885 ms
62,140 KB
testcase_14 AC 871 ms
62,168 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 917 ms
62,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 890 ms
62,124 KB
testcase_24 AC 902 ms
62,360 KB
testcase_25 AC 884 ms
62,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

object Main {

  def solve(s: String): Long = {
    var answer = 0
    var w = 0
    for (ch <- s.reverse){
      if (ch == 'w') {
        w += 1
      } else if (ch == 'c') {
        answer += w * (w - 1) / 2
      }
    }
    return answer
  }

  def main(args: Array[String]): Unit = {
    println(solve(scala.io.StdIn.readLine()))
  }

}
0