結果

問題 No.346 チワワ数え上げ問題
ユーザー spaciaspacia
提出日時 2016-06-02 16:55:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 54,792 KB
最終ジャッジ日時 2024-04-16 23:05:58
合計ジャッジ時間 6,821 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,236 KB
testcase_01 AC 118 ms
41,668 KB
testcase_02 AC 116 ms
41,404 KB
testcase_03 AC 109 ms
41,424 KB
testcase_04 AC 115 ms
41,148 KB
testcase_05 AC 113 ms
41,204 KB
testcase_06 AC 100 ms
41,204 KB
testcase_07 AC 115 ms
41,520 KB
testcase_08 AC 116 ms
41,440 KB
testcase_09 AC 102 ms
41,440 KB
testcase_10 WA -
testcase_11 AC 166 ms
42,136 KB
testcase_12 WA -
testcase_13 AC 169 ms
41,880 KB
testcase_14 AC 113 ms
41,488 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 174 ms
42,464 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 119 ms
41,456 KB
testcase_24 AC 117 ms
41,196 KB
testcase_25 AC 116 ms
41,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		System.out.println(solve(sc.next()));

		sc.close();

	}

	public static int solve (String s) {
		int wcnt = 0, sum = 0;
		int len = s.length();
		for (int i = len - 1; i >= 0; i--) {
			if (s.charAt(i) == 'w') {
				wcnt++;
				continue;
			}
			if (s.charAt(i) == 'c')
				sum += wcnt * (wcnt - 1) / 2;
		}
		return sum;
	}

}
0