結果

問題 No.436 ccw
ユーザー yagi2
提出日時 2017-04-15 19:22:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 74,768 KB
実行使用メモリ 42,660 KB
最終ジャッジ日時 2024-07-18 18:01:26
合計ジャッジ時間 6,591 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        int c = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == 'w')break;
            if (S.charAt(i) == 'c') {
                c++;
            }
        }
        int w = S.length() - c;

        if (c <= w) {
            System.out.println(c-1);
        } else if (c > w) {
            System.out.println(w);
        }
    }
}
0