結果
問題 |
No.3302 Sense Battle
|
ユーザー |
![]() |
提出日時 | 2025-10-05 15:55:52 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 555 ms / 2,000 ms |
コード長 | 2,769 bytes |
コンパイル時間 | 10,050 ms |
コンパイル使用メモリ | 170,604 KB |
実行使用メモリ | 218,628 KB |
最終ジャッジ日時 | 2025-10-05 15:56:50 |
合計ジャッジ時間 | 18,177 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (117 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("4"); WillReturn.Add("200 100"); WillReturn.Add("300 500"); WillReturn.Add("500 200"); WillReturn.Add("700 100"); //1500 } else if (InputPattern == "Input2") { WillReturn.Add("1"); WillReturn.Add("1000000000 1"); //1 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static long[] GetSplitArr(string pStr) { pStr = pStr.TrimEnd(); return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray(); } struct ItemInfoDef { internal long AddPower; internal long AttackPlus; } static List<ItemInfoDef> mItemInfoList = new List<ItemInfoDef>(); static void Main() { List<string> InputList = GetInputList(); long[] wkArr = { }; Action<string> SplitAct = (pStr) => wkArr = GetSplitArr(pStr); foreach (string EachStr in InputList.Skip(1)) { SplitAct(EachStr); ItemInfoDef WillAdd; WillAdd.AddPower = wkArr[0]; WillAdd.AttackPlus = wkArr[1]; mItemInfoList.Add(WillAdd); } mItemInfoList.Reverse(); long UB = mItemInfoList.Count - 1; // 最大スコア[攻撃回数]なDP表 long?[] PrevDP = new long?[UB + 10]; PrevDP[0] = 0; long Answer = long.MinValue; foreach (ItemInfoDef EachItemInfo in mItemInfoList) { long?[] CurrDP = new long?[UB + 10]; for (long I = 0; I <= UB + 5; I++) { if (PrevDP[I].HasValue == false) continue; Action<long, long> UpdateAct = (pNewInd, pNewVal) => { if (CurrDP[pNewInd].HasValue) { if (CurrDP[pNewInd] >= pNewVal) { return; } } CurrDP[pNewInd] = pNewVal; Answer = Math.Max(Answer, pNewVal); }; // 攻撃する場合 UpdateAct(I + 1, PrevDP[I].Value + EachItemInfo.AttackPlus); // 力を増やす場合 UpdateAct(I, PrevDP[I].Value + EachItemInfo.AddPower * I); } PrevDP = CurrDP; } Console.WriteLine(Answer); } }