結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー | tenten |
提出日時 | 2023-02-15 11:05:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 1,746 bytes |
コンパイル時間 | 5,661 ms |
コンパイル使用メモリ | 86,336 KB |
実行使用メモリ | 52,332 KB |
最終ジャッジ日時 | 2023-09-24 20:58:33 |
合計ジャッジ時間 | 6,342 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
49,300 KB |
testcase_01 | AC | 45 ms
49,364 KB |
testcase_02 | AC | 44 ms
49,508 KB |
testcase_03 | AC | 45 ms
49,240 KB |
testcase_04 | AC | 49 ms
49,344 KB |
testcase_05 | AC | 45 ms
49,356 KB |
testcase_06 | AC | 45 ms
49,348 KB |
testcase_07 | AC | 45 ms
49,600 KB |
testcase_08 | AC | 45 ms
49,444 KB |
testcase_09 | AC | 45 ms
49,712 KB |
testcase_10 | AC | 95 ms
52,004 KB |
testcase_11 | AC | 77 ms
51,416 KB |
testcase_12 | AC | 90 ms
52,280 KB |
testcase_13 | AC | 76 ms
51,568 KB |
testcase_14 | AC | 47 ms
49,328 KB |
testcase_15 | AC | 76 ms
50,332 KB |
testcase_16 | AC | 82 ms
52,332 KB |
testcase_17 | AC | 97 ms
51,728 KB |
testcase_18 | AC | 94 ms
51,984 KB |
testcase_19 | AC | 78 ms
52,252 KB |
testcase_20 | AC | 95 ms
51,988 KB |
testcase_21 | AC | 77 ms
52,104 KB |
testcase_22 | AC | 93 ms
52,012 KB |
testcase_23 | AC | 45 ms
49,256 KB |
testcase_24 | AC | 46 ms
49,328 KB |
testcase_25 | AC | 44 ms
49,864 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long cCount = 0; long wCount = 0; long ans = 0; for (char c : sc.next().toCharArray()) { if (c == 'c') { cCount++; } else if (c == 'w') { ans += wCount; wCount += cCount; } } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }