結果

問題 No.279 木の数え上げ
コンテスト
ユーザー monburan_0401
提出日時 2018-09-09 23:32:36
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 660 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 165 ms
コンパイル使用メモリ 38,336 KB
最終ジャッジ日時 2026-02-22 01:43:43
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//	与えられる文字列から tree がいくつ作れるか
#include <stdio.h>
int main(void){
	char S;	//	S[i]. 1 <= i <= 10^6
	int change;
	int t,r,e;	//	treeの判断材料
	int count = 0;	//	treeの個数
	t = r = e = 0;
	
	while((S = getchar()) != EOF){
		//printf("%c",S);		//	check ok
		//	tree を探す
		if(S == 't'){
			t += 1;
		}
		else if(S == 'r'){
			r += 1;
		}
		else if(S == 'e'){
			e += 1;
		}
		
//		printf("t = %d r = %d e = %d\n",t,r,e);		//	check	ok
		
		if( (t >= 1)&&(r >= 1)&&(e >= 2) ){
			t -= 1;
			r -= 1;
			e -= 2;
			count += 1;
		}
		
//		printf("%d\n",count);		//	check	ok
		
	}
	
	printf("%d\n",count);
	return 0;
}
0