結果

問題 No.436 ccw
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-21 19:22:35
言語 Java19
(openjdk 21)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 74,596 KB
実行使用メモリ 58,164 KB
最終ジャッジ日時 2023-10-19 03:44:03
合計ジャッジ時間 8,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,456 KB
testcase_01 AC 133 ms
57,712 KB
testcase_02 AC 135 ms
57,244 KB
testcase_03 AC 136 ms
57,224 KB
testcase_04 AC 132 ms
57,228 KB
testcase_05 AC 134 ms
57,484 KB
testcase_06 AC 135 ms
56,984 KB
testcase_07 AC 133 ms
57,208 KB
testcase_08 AC 132 ms
57,228 KB
testcase_09 AC 133 ms
57,504 KB
testcase_10 AC 132 ms
57,236 KB
testcase_11 AC 134 ms
57,492 KB
testcase_12 AC 134 ms
57,460 KB
testcase_13 AC 133 ms
57,472 KB
testcase_14 AC 137 ms
56,984 KB
testcase_15 AC 132 ms
57,144 KB
testcase_16 AC 156 ms
57,700 KB
testcase_17 AC 142 ms
57,168 KB
testcase_18 AC 148 ms
57,164 KB
testcase_19 AC 153 ms
57,160 KB
testcase_20 AC 154 ms
57,256 KB
testcase_21 AC 215 ms
57,872 KB
testcase_22 AC 222 ms
58,104 KB
testcase_23 AC 222 ms
58,164 KB
testcase_24 AC 223 ms
58,144 KB
testcase_25 AC 224 ms
57,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		int c_num = 0;
		int w_num = 0;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i)=='c') {c_num++;}
			else {w_num++;}
		}
		
		if (c_num-1 >= w_num) {
			System.out.println(w_num);
		}
		else if (c_num-1 < w_num) {
			System.out.println(c_num-1);
		}
	}
}
0