結果

問題 No.346 チワワ数え上げ問題
ユーザー htensaihtensai
提出日時 2019-11-21 17:50:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 2,407 ms
コンパイル使用メモリ 77,760 KB
実行使用メモリ 42,804 KB
最終ジャッジ日時 2024-04-19 02:13:34
合計ジャッジ時間 7,612 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,380 KB
testcase_01 AC 122 ms
41,648 KB
testcase_02 AC 122 ms
41,560 KB
testcase_03 AC 111 ms
41,520 KB
testcase_04 AC 127 ms
41,308 KB
testcase_05 AC 124 ms
41,644 KB
testcase_06 AC 125 ms
41,272 KB
testcase_07 AC 123 ms
41,320 KB
testcase_08 AC 128 ms
41,288 KB
testcase_09 AC 123 ms
41,332 KB
testcase_10 AC 186 ms
42,576 KB
testcase_11 AC 177 ms
42,804 KB
testcase_12 AC 187 ms
42,340 KB
testcase_13 AC 178 ms
41,720 KB
testcase_14 AC 143 ms
41,320 KB
testcase_15 AC 179 ms
42,200 KB
testcase_16 AC 181 ms
42,660 KB
testcase_17 AC 182 ms
42,492 KB
testcase_18 AC 193 ms
42,572 KB
testcase_19 AC 182 ms
42,476 KB
testcase_20 AC 181 ms
42,648 KB
testcase_21 AC 188 ms
42,432 KB
testcase_22 AC 186 ms
42,588 KB
testcase_23 AC 122 ms
41,592 KB
testcase_24 AC 125 ms
42,112 KB
testcase_25 AC 124 ms
41,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		long cCount = 0;
		long cwCount = 0;
		long sum = 0;
		for (char c : arr) {
		    if (c == 'c') {
		        cCount++;
		    } else if (c == 'w') {
		        sum += cwCount;
		        cwCount += cCount;
		    }
		}
		System.out.println(sum);
	}
}
0