結果

問題 No.346 チワワ数え上げ問題
ユーザー yun_app
提出日時 2016-05-09 19:26:38
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,028 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 43,384 KB
最終ジャッジ日時 2024-10-05 13:08:43
合計ジャッジ時間 7,933 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 14 WA * 7 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

/* 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;
    }
}
0