結果

問題 No.1159 Sashiming String
ユーザー bluemeganebluemegane
提出日時 2021-05-19 18:37:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 108,216 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-18 05:21:49
合計ジャッジ時間 1,867 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,304 KB
testcase_01 AC 26 ms
18,304 KB
testcase_02 AC 30 ms
18,688 KB
testcase_03 AC 31 ms
19,456 KB
testcase_04 AC 28 ms
18,560 KB
testcase_05 AC 31 ms
19,072 KB
testcase_06 AC 29 ms
18,816 KB
testcase_07 AC 29 ms
18,944 KB
testcase_08 AC 35 ms
19,456 KB
testcase_09 AC 34 ms
19,456 KB
testcase_10 AC 23 ms
17,408 KB
testcase_11 AC 22 ms
17,536 KB
testcase_12 AC 26 ms
18,432 KB
testcase_13 AC 26 ms
18,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        if (s.Length < 4) Console.WriteLine(0);
        else getAns(s);
    }
    static int[] seachS(string s)
    {
        var sL = s.Length;
        var res = new int[sL];
        res[0] = s[0] == 'S' ? 1 : 0;
        for (int i = 1; i < sL; i++) res[i] = s[i] == 'S' ? res[i - 1] + 1 : res[i - 1];
        return res;
    }
    static void getAns(string s)
    {
        var ans = 0L;
        var ps = seachS(s);
        var sL = s.Length;
        var p = 0;
        while (p < sL)
        {
            var p2 = s.IndexOf("ing", p);
            if (p2 != -1) ans += ps[p2 - 1];
            else break;
            p = p2 + 3;
        }
        Console.WriteLine(ans);
    }
}
0