結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー | yun_app |
提出日時 | 2016-05-09 19:26:38 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,028 bytes |
コンパイル時間 | 2,357 ms |
コンパイル使用メモリ | 75,576 KB |
実行使用メモリ | 51,692 KB |
最終ジャッジ日時 | 2024-04-15 14:56:24 |
合計ジャッジ時間 | 8,141 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
42,468 KB |
testcase_01 | AC | 56 ms
36,692 KB |
testcase_02 | AC | 54 ms
36,800 KB |
testcase_03 | AC | 57 ms
37,188 KB |
testcase_04 | AC | 54 ms
37,224 KB |
testcase_05 | AC | 54 ms
36,960 KB |
testcase_06 | AC | 55 ms
37,004 KB |
testcase_07 | AC | 56 ms
37,020 KB |
testcase_08 | AC | 55 ms
36,680 KB |
testcase_09 | AC | 56 ms
36,980 KB |
testcase_10 | WA | - |
testcase_11 | AC | 120 ms
43,072 KB |
testcase_12 | WA | - |
testcase_13 | AC | 128 ms
43,004 KB |
testcase_14 | AC | 63 ms
37,120 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 92 ms
39,844 KB |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); ArrayList<Integer> w_num = new ArrayList<Integer>(); for(int i=0;i<line.length();i++){ char c = line.charAt(i); if(c == 'c'){ w_num.add(0); }else if(c == 'w'){ for(int j=0;j<w_num.size();j++){ w_num.set(j,w_num.get(j)+1); } } } int ans = 0; for(int w:w_num){ ans += combination(w); } System.out.println(ans); } public static int combination(int n){ return (n * (n-1)) / 2; } }