結果
| 問題 |
No.279 木の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-17 22:40:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 673 bytes |
| コンパイル時間 | 394 ms |
| コンパイル使用メモリ | 45,416 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 00:33:51 |
| 合計ジャッジ時間 | 1,792 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s",S);
| ~~~~~^~~~~~~~
ソースコード
#include <stdio.h>
#include <string>
#include <algorithm>
int main(){
//input
char S[1000001];
scanf("%s",S);
//count 't','r','e'
int count_t = 0;
int count_r = 0;
int count_e = 0;
for (int i = 0;i < 1000001;i++){
if (S[i] != '\0'){
if (S[i] == 't') count_t++;
if (S[i] == 'r') count_r++;
if (S[i] == 'e') count_e++;
}else{
break;
}
}
//count 'tr','ee','tree'
int count_tr = std::min(count_t,count_r);
int count_ee = (count_e-count_e%2)/2;
int count_tree = std::min(count_tr,count_ee);
//output
printf("%d\n",count_tree);
return 0;
}