結果

問題 No.1159 Sashiming String
ユーザー ThetaTheta
提出日時 2022-11-14 18:16:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 878 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 13,060 KB
最終ジャッジ日時 2023-10-14 01:08:07
合計ジャッジ時間 6,919 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,780 KB
testcase_01 AC 15 ms
7,896 KB
testcase_02 AC 267 ms
8,196 KB
testcase_03 AC 878 ms
8,432 KB
testcase_04 AC 215 ms
8,320 KB
testcase_05 AC 499 ms
8,588 KB
testcase_06 AC 208 ms
8,264 KB
testcase_07 AC 386 ms
8,436 KB
testcase_08 AC 814 ms
10,600 KB
testcase_09 AC 860 ms
13,060 KB
testcase_10 AC 16 ms
7,820 KB
testcase_11 AC 15 ms
7,828 KB
testcase_12 AC 16 ms
7,804 KB
testcase_13 AC 15 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

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