結果

問題 No.436 ccw
ユーザー CrazyBBB
提出日時 2016-10-28 22:23:57
言語 Java8
(openjdk 1.8.0.222)
結果
AC  
実行時間 107 ms
コード長 1,816 Byte
コンパイル時間 1,464 ms
使用メモリ 32,592 KB
最終ジャッジ日時 2019-10-11 11:11:32

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample01.txt AC 76 ms
28,860 KB
00_sample02.txt AC 76 ms
30,588 KB
01_hand01.txt AC 79 ms
32,584 KB
01_hand02.txt AC 77 ms
29,444 KB
01_hand03.txt AC 79 ms
29,408 KB
01_hand04.txt AC 78 ms
28,856 KB
01_hand05.txt AC 78 ms
30,828 KB
01_hand06.txt AC 77 ms
30,964 KB
01_hand07.txt AC 77 ms
28,860 KB
01_hand08.txt AC 79 ms
32,172 KB
01_hand09.txt AC 78 ms
31,796 KB
in01.txt AC 79 ms
32,112 KB
in02.txt AC 79 ms
30,344 KB
in03.txt AC 79 ms
32,196 KB
in04.txt AC 80 ms
32,592 KB
in05.txt AC 79 ms
30,972 KB
in06.txt AC 81 ms
31,284 KB
in07.txt AC 79 ms
30,588 KB
in08.txt AC 82 ms
31,288 KB
in09.txt AC 79 ms
31,412 KB
in10.txt AC 79 ms
30,584 KB
in11.txt AC 105 ms
31,456 KB
in12.txt AC 104 ms
30,692 KB
in13.txt AC 107 ms
31,408 KB
in14.txt AC 106 ms
31,408 KB
in15.txt AC 103 ms
31,688 KB
テストケース一括ダウンロード

ソースコード

diff #
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        String s = ns();
        int cnt = 0;
        int cnt2 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'c') cnt++;
            else cnt2++;
        }

        out.println(Math.min(cnt - 1, cnt2));
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0