結果

問題 No.346 チワワ数え上げ問題
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-02-27 17:39:14
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 7,598 ms
コンパイル使用メモリ 244,516 KB
実行使用メモリ 62,976 KB
最終ジャッジ日時 2023-09-11 23:51:04
合計ジャッジ時間 32,885 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 854 ms
61,496 KB
testcase_01 AC 835 ms
61,520 KB
testcase_02 AC 842 ms
61,440 KB
testcase_03 AC 832 ms
61,452 KB
testcase_04 AC 845 ms
61,560 KB
testcase_05 AC 843 ms
61,528 KB
testcase_06 AC 843 ms
61,504 KB
testcase_07 AC 843 ms
61,464 KB
testcase_08 AC 845 ms
61,504 KB
testcase_09 AC 840 ms
61,424 KB
testcase_10 WA -
testcase_11 AC 852 ms
61,428 KB
testcase_12 WA -
testcase_13 AC 858 ms
61,596 KB
testcase_14 AC 843 ms
61,844 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 864 ms
61,588 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 848 ms
61,628 KB
testcase_24 AC 846 ms
61,564 KB
testcase_25 AC 842 ms
61,396 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