結果
| 問題 | No.3760 Streaming Schedule |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-09 22:48:42 |
| 言語 | C# (.NET 10.0.400 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,850 bytes |
| 記録 | |
| コンパイル時間 | 10,446 ms |
| コンパイル使用メモリ | 173,052 KB |
| 実行使用メモリ | 91,108 KB |
| 最終ジャッジ日時 | 2026-10-09 22:49:01 |
| 合計ジャッジ時間 | 16,199 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 30 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (205 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
#nullable enable
#region
var (_input, _iter) = (Array.Empty<string>(), 0);
T I<T>() where T : IParsable<T>
{
while (_iter >= _input.Length) (_input, _iter) = (Console.ReadLine()!.Split(' ', StringSplitOptions.RemoveEmptyEntries), 0);
return T.Parse(_input[_iter++], null);
}
#endregion
var n = I<int>();
var b = Math.Min(I<int>(), 3);
var c = I<int>();
var az = Enumerable.Range(0, n).Select(_ => I<int>()).ToArray();
var s = 0L;
foreach (var a in az) s += a;
var op = new Op();
var dp = new SegmentTree<long, Op>([.. Enumerable.Range(0, n + 1).Select(_ => op.IdentityElement)], op);
dp.Set(0, 0);
var last = 0L;
var suc = op.IdentityElement;
for (var i = 1; i <= n; i++)
{
var a = az[i - 1];
var min = dp.Product(Math.Max(0, i - c), i - 1);
dp.Set(i, min + a);
if (b > 2) dp.Set(i - 1, Math.Min(suc, dp.Product(i - 1, i)));
suc = last + a;
last = min + a;
}
var ans = s - dp.Product(n - c, n + 1);
Console.WriteLine(ans);
readonly struct Op : ISegmentTreeOperator<long>
{
public long IdentityElement => long.MaxValue / 8;
public long Operation(long x, long y) => long.Min(x, y);
}
interface ISegmentTreeOperator<TMonoid>
{
TMonoid IdentityElement { get; }
TMonoid Operation(TMonoid x, TMonoid y);
}
class SegmentTree<TMonoid, TOperator> where TOperator : struct, ISegmentTreeOperator<TMonoid>
{
public int BaseSize { get; protected init; }
protected int Height { get; init; }
protected TOperator Op { get; init; }
protected TMonoid[] Values { get; init; }
public SegmentTree(TMonoid[] initial, TOperator op = default)
{
Op = op;
(BaseSize, Height) = (1, 0);
while (BaseSize < initial.Length) (BaseSize, Height) = (BaseSize << 1, Height + 1);
var size = BaseSize << 1;
Values = new TMonoid[size];
var values = Values;
for (var i = 0; i < size; i++) values[i] = op.IdentityElement;
for (var i = 0; i < initial.Length; i++) values[i + BaseSize] = initial[i];
for (var i = BaseSize - 1; i > 0; i--) Update(values, i);
}
public TMonoid Product(int l, int r)
{
(l, r) = (l + BaseSize, r + BaseSize);
var (resL, resR) = (Op.IdentityElement, Op.IdentityElement);
var values = Values;
while (l < r)
{
if ((l & 1) == 1) resL = Op.Operation(resL, values[l++]);
if ((r & 1) == 1) resR = Op.Operation(values[--r], resR);
(l, r) = (l >> 1, r >> 1);
}
return Op.Operation(resL, resR);
}
public void Set(int index, TMonoid value)
{
var j = index + BaseSize;
var values = Values;
values[j] = value;
while ((j >>= 1) > 0) Update(values, j);
}
protected void Update(TMonoid[] values, int k) { values[k] = Op.Operation(values[k << 1], values[(k << 1) + 1]); }
}