結果

問題 No.1534 おなかがいたい
ユーザー kokatsukokatsu
提出日時 2022-02-23 21:51:48
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 11,604 ms
コンパイル使用メモリ 701,744 KB
実行使用メモリ 4,808 KB
最終ジャッジ日時 2023-09-04 16:07:58
合計ジャッジ時間 11,387 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,460 KB
testcase_01 AC 2 ms
4,444 KB
testcase_02 AC 2 ms
4,464 KB
testcase_03 AC 2 ms
4,456 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,484 KB
testcase_06 AC 1 ms
4,460 KB
testcase_07 AC 2 ms
4,492 KB
testcase_08 AC 2 ms
4,504 KB
testcase_09 AC 1 ms
4,452 KB
testcase_10 AC 1 ms
4,448 KB
testcase_11 AC 2 ms
4,480 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,704 KB
testcase_14 AC 13 ms
4,732 KB
testcase_15 AC 13 ms
4,736 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 10 ms
4,728 KB
testcase_20 AC 9 ms
4,748 KB
testcase_21 AC 2 ms
4,460 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    string S = readln.chomp;

    auto r = regex(r"p.n");
    auto T = S.splitter!(Yes.keepSeparators)(r);

    bool isOK = true;
    string a = "pon", b = "pain";
    int res, num = -1;
    foreach (t; T) {
        if (t == a) ++num;
        else if (t == b && isOK) {
            res = max(res, num);
            isOK = false;
        }
    }

    if (res == 0) res = -1;

    res.writeln;
}
0