結果

問題 No.1159 Sashiming String
ユーザー Theta
提出日時 2022-11-14 18:16:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 939 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 15,664 KB
最終ジャッジ日時 2024-09-15 20:52:54
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    S = input()
    S_reverse = S[::-1]
    ing_count = [0]

    for idx, letter in enumerate(S_reverse):
        if S_reverse[idx:].startswith("gni"):
            ing_count[-1] += 1
        if letter == "S":
            ing_count.append(0)

    ing_count = ing_count[:-1]
    if not ing_count:
        print(0)
        return

    ing_count_partial_sum = []
    for count_ in ing_count:
        if not ing_count_partial_sum:
            ing_count_partial_sum.append(count_)
        else:
            ing_count_partial_sum.append(ing_count_partial_sum[-1]+count_)
    print(sum(ing_count_partial_sum))


if __name__ == "__main__":
    main()
0