結果
問題 |
No.2150 Site Supporter
|
ユーザー |
|
提出日時 | 2023-01-15 20:51:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 899 bytes |
コンパイル時間 | 5,403 ms |
コンパイル使用メモリ | 106,368 KB |
実行使用メモリ | 44,672 KB |
最終ジャッジ日時 | 2024-12-29 12:39:29 |
合計ジャッジ時間 | 5,110 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, k, x) = (c[0], c[1], c[2]); var a = NList; var dp = new long[2][]; for (var i = 0; i < dp.Length; ++i) dp[i] = Enumerable.Repeat(long.MaxValue / 2, n + 1).ToArray(); dp[0][0] = 0; for (var i = 0; i < n; ++i) { dp[0][i + 1] = Math.Min(dp[0][i], dp[1][i]) + a[i]; dp[1][i + 1] = Math.Min(dp[0][i] + k + x, dp[1][i] + k); } WriteLine(Math.Min(dp[0][n], dp[1][n])); } }