結果
| 問題 |
No.279 木の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-12 18:17:55 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 344 ms / 2,000 ms |
| コード長 | 653 bytes |
| コンパイル時間 | 2,122 ms |
| コンパイル使用メモリ | 74,332 KB |
| 実行使用メモリ | 50,916 KB |
| 最終ジャッジ日時 | 2024-11-17 10:53:22 |
| 合計ジャッジ時間 | 7,435 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
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;
}
}