結果

問題 No.1535 五七五
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-08 20:27:54
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 1,131 ms / 2,000 ms
コード長 1,478 bytes
コンパイル時間 9,149 ms
コンパイル使用メモリ 169,164 KB
実行使用メモリ 237,060 KB
最終ジャッジ日時 2024-06-08 20:28:13
合計ジャッジ時間 18,318 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
29,952 KB
testcase_01 AC 54 ms
30,336 KB
testcase_02 AC 54 ms
30,080 KB
testcase_03 AC 53 ms
30,464 KB
testcase_04 AC 1,100 ms
61,312 KB
testcase_05 AC 944 ms
105,580 KB
testcase_06 AC 1,131 ms
105,840 KB
testcase_07 AC 55 ms
30,464 KB
testcase_08 AC 54 ms
30,336 KB
testcase_09 AC 58 ms
30,464 KB
testcase_10 AC 54 ms
30,464 KB
testcase_11 AC 54 ms
30,208 KB
testcase_12 AC 52 ms
30,080 KB
testcase_13 AC 54 ms
30,296 KB
testcase_14 AC 52 ms
30,080 KB
testcase_15 AC 51 ms
30,592 KB
testcase_16 AC 53 ms
29,952 KB
testcase_17 AC 52 ms
30,080 KB
testcase_18 AC 518 ms
82,540 KB
testcase_19 AC 511 ms
82,432 KB
testcase_20 AC 516 ms
82,412 KB
testcase_21 AC 542 ms
82,304 KB
testcase_22 AC 519 ms
82,688 KB
testcase_23 AC 517 ms
237,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (90 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] SList => ReadLine().Split().Select(s => s.Length).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var c = NList;
        var s = SList;
        var cum = new int[n + 1];
        for (var i = 0; i < n; ++i) cum[i + 1] = cum[i] + s[i];
        var ans = 0;
        for (var i = 0; i < n; ++i)
        {
            var pos1 = LowerBound(0, cum[i] + c[0], cum);
            if (pos1 > n || cum[pos1] - cum[i] != c[0]) continue;
            var pos2 = LowerBound(0, cum[pos1] + c[1], cum);
            if (pos2 > n || cum[pos2] - cum[pos1] != c[1]) continue;
            var pos3 = LowerBound(0, cum[pos2] + c[2], cum);
            if (pos3 > n) continue;
            if (cum[pos3] - cum[pos2] == c[2]) ++ans;
        }
        WriteLine(ans);
    }
    static int LowerBound(int left, int min, IList<int> list)
    {
        if (list[left] >= min) return left;
        var ng = left;
        var ok = list.Count;
        while (ok - ng > 1)
        {
            var center = (ng + ok) / 2;
            if (list[center] < min) ng = center;
            else ok = center;
        }
        return ok;
    }
}
0