結果
| 問題 |
No.3302 Sense Battle
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-10-15 16:23:29 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 477 ms / 2,000 ms |
| コード長 | 2,729 bytes |
| コンパイル時間 | 7,232 ms |
| コンパイル使用メモリ | 169,444 KB |
| 実行使用メモリ | 192,332 KB |
| 最終ジャッジ日時 | 2025-10-15 16:23:47 |
| 合計ジャッジ時間 | 15,076 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (103 ミリ秒)。 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;
// https://yukicoder.me/problems/no/3302
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;
// 最大スコア[攻撃回数]なインラインDP表
long?[] DPArr = new long?[UB + 1];
DPArr[0] = 0;
long Answer = long.MinValue;
foreach (ItemInfoDef EachItemInfo in mItemInfoList) {
for (long I = UB; 0 <= I; I--) {
if (DPArr[I].HasValue == false) continue;
Action<long, long> UpdateAct = (pNewInd, pNewVal) =>
{
if (DPArr[pNewInd].HasValue) {
if (DPArr[pNewInd] >= pNewVal) {
return;
}
}
DPArr[pNewInd] = pNewVal;
Answer = Math.Max(Answer, pNewVal);
};
// 攻撃する場合
UpdateAct(I + 1, DPArr[I].Value + EachItemInfo.AttackPlus);
// 力を増やす場合
UpdateAct(I, DPArr[I].Value + EachItemInfo.AddPower * I);
}
}
Console.WriteLine(Answer);
}
}
aketijyuuzou