結果

問題 No.279 木の数え上げ
ユーザー wf4n9wf4n9
提出日時 2017-10-12 18:17:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 74,868 KB
実行使用メモリ 51,004 KB
最終ジャッジ日時 2024-04-28 17:07:34
合計ジャッジ時間 8,067 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,704 KB
testcase_01 AC 126 ms
41,404 KB
testcase_02 AC 130 ms
40,880 KB
testcase_03 AC 130 ms
41,148 KB
testcase_04 AC 131 ms
41,372 KB
testcase_05 AC 130 ms
41,404 KB
testcase_06 AC 115 ms
39,840 KB
testcase_07 AC 128 ms
41,320 KB
testcase_08 AC 131 ms
41,136 KB
testcase_09 AC 129 ms
41,284 KB
testcase_10 AC 355 ms
49,744 KB
testcase_11 AC 271 ms
43,552 KB
testcase_12 AC 356 ms
50,120 KB
testcase_13 AC 222 ms
43,012 KB
testcase_14 AC 363 ms
50,036 KB
testcase_15 AC 351 ms
51,004 KB
testcase_16 AC 355 ms
50,648 KB
testcase_17 AC 361 ms
50,036 KB
testcase_18 AC 300 ms
48,068 KB
testcase_19 AC 362 ms
49,540 KB
testcase_20 AC 354 ms
49,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		System.out.println(countTrees(input));
	}
	public static int countTrees(final String input) {

		int tQty = 0;
		int rQty = 0;
		int eQty = 0;

		for(int i = 0; i < input.length(); i++) {
			if(input.charAt(i) == 't') {
				tQty++;
			}
			if(input.charAt(i) == 'r') {
				rQty++;
			}
			if(input.charAt(i) == 'e') {
				eQty++;
			}
		}
		eQty /= 2;
		int treeQty = 0;
		while (tQty > 0 && rQty > 0 && eQty > 0) {
			tQty--;
			rQty--;
			eQty--;
			treeQty++;
		}
		return treeQty;
	}
}
0