結果
| 問題 | No.1535 五七五 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-08 20:27:54 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 2,000 ms |
| コード長 | 1,478 bytes |
| 記録 | |
| コンパイル時間 | 9,714 ms |
| コンパイル使用メモリ | 175,236 KB |
| 実行使用メモリ | 247,408 KB |
| 最終ジャッジ日時 | 2026-06-02 16:39:20 |
| 合計ジャッジ時間 | 15,115 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (107 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
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;
}
}