結果
| 問題 |
No.2298 yukicounter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-12 21:40:40 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,030 bytes |
| コンパイル時間 | 1,577 ms |
| コンパイル使用メモリ | 169,616 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 17:55:03 |
| 合計ジャッジ時間 | 2,967 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import std;
void main () {
string S = readln.split[0];
solve(S);
}
void solve (string S) {
int ans = 0;
while ("yukicoder".length <= S.length) {
if (S[0] == 'y') {
auto tmp = HowMany_included(S, "yukicoder");
ans = tmp > ans ? tmp : ans;
} else {
S = S[1..$];
}
}
writeln(ans);
}
int HowMany_included (ref string base, string key) {
if (base.length < key.length) {
return 0;
}
int ret = 0;
while (key.length <= base.length) {
bool is_included = true;
int cut = -1;
foreach (j; 0..key.length) {
if (base[j] != key[j]) {
is_included = false;
cut = cast(int)j;
break;
}
}
if (cut == -1) {
base = base[9..$];
} else {
base = base[cut + 1..$];
}
if (is_included) {
ret++;
} else {
return ret;
}
}
return ret;
}