結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2016-05-09 19:28:31 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,029 bytes |
コンパイル時間 | 2,239 ms |
コンパイル使用メモリ | 75,952 KB |
実行使用メモリ | 51,456 KB |
最終ジャッジ日時 | 2024-10-05 13:09:07 |
合計ジャッジ時間 | 8,044 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 21 TLE * 1 -- * 1 |
ソースコード
/* 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); } } } long 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; } }