結果

問題 No.346 チワワ数え上げ問題
ユーザー nglkrianbrjfnglkrianbrjf
提出日時 2016-02-26 23:03:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 3,597 ms
コンパイル使用メモリ 74,880 KB
実行使用メモリ 55,584 KB
最終ジャッジ日時 2023-10-24 05:50:13
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,408 KB
testcase_01 AC 55 ms
53,408 KB
testcase_02 AC 62 ms
53,416 KB
testcase_03 AC 55 ms
53,408 KB
testcase_04 AC 56 ms
53,404 KB
testcase_05 AC 56 ms
52,400 KB
testcase_06 AC 57 ms
53,404 KB
testcase_07 AC 57 ms
53,412 KB
testcase_08 AC 54 ms
53,412 KB
testcase_09 AC 56 ms
53,428 KB
testcase_10 WA -
testcase_11 AC 90 ms
54,776 KB
testcase_12 WA -
testcase_13 AC 89 ms
54,788 KB
testcase_14 AC 57 ms
53,412 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 105 ms
54,724 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 56 ms
53,436 KB
testcase_24 AC 55 ms
53,444 KB
testcase_25 AC 56 ms
53,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class QuestionA {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;

		try{
			line = in.readLine();
		}catch(IOException e){
			System.out.println("0");
			return;
		}

		int[] c = new int[100000];
		Arrays.fill(c, 0);

		int result = 0;
		int ccount = 0;//直前のcの位置

		for(int i = 0; i < line.length(); i++){
			if(line.charAt(i) == 'c')
				ccount++;
			if(line.charAt(i) == 'w'){
				for(int j = 0; j < ccount; j++)
					c[j]++;
			}
		}
		for(int i = 0; i < ccount; i++){
			result += c[i] * (c[i]-1)/2;
		}


		System.out.println(result);
	}

}
0