結果

問題 No.37 遊園地のアトラクション
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-08 17:02:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 1,713 bytes
コンパイル時間 1,101 ms
コンパイル使用メモリ 115,596 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-04-18 19:41:05
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
19,072 KB
testcase_01 AC 30 ms
19,456 KB
testcase_02 AC 31 ms
19,328 KB
testcase_03 AC 32 ms
19,200 KB
testcase_04 AC 30 ms
19,456 KB
testcase_05 AC 31 ms
19,328 KB
testcase_06 AC 30 ms
19,072 KB
testcase_07 AC 34 ms
19,456 KB
testcase_08 AC 29 ms
19,328 KB
testcase_09 AC 30 ms
19,328 KB
testcase_10 AC 35 ms
19,328 KB
testcase_11 AC 33 ms
19,328 KB
testcase_12 AC 31 ms
19,456 KB
testcase_13 AC 32 ms
19,200 KB
testcase_14 AC 31 ms
19,328 KB
testcase_15 AC 32 ms
19,584 KB
testcase_16 AC 31 ms
19,072 KB
testcase_17 AC 31 ms
19,456 KB
testcase_18 AC 35 ms
19,456 KB
testcase_19 AC 29 ms
19,200 KB
testcase_20 AC 32 ms
19,328 KB
testcase_21 AC 30 ms
19,072 KB
testcase_22 AC 34 ms
19,072 KB
testcase_23 AC 30 ms
19,200 KB
testcase_24 AC 29 ms
19,456 KB
testcase_25 AC 29 ms
19,328 KB
testcase_26 AC 29 ms
19,328 KB
testcase_27 AC 32 ms
19,200 KB
testcase_28 AC 29 ms
19,328 KB
testcase_29 AC 30 ms
19,072 KB
testcase_30 AC 30 ms
19,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();
        string wkStr;
        while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int T = int.Parse(InputList[0]);
        int[] CArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] VArr = InputList[3].Split(' ').Select(X => int.Parse(X)).ToArray();

        //添字が時間の合計、値が満足度合計の最大値
        var SumVArr = new Nullable<int>[T + 1];
        SumVArr[0] = 0;

        int KasanValue = 0;
        for (int LoopI = 0; LoopI <= CArr.GetUpperBound(0); LoopI += KasanValue) {
            for (int LoopJ = T; 0 <= LoopJ; LoopJ--) {
                //時間制限を超えてしまう場合
                int wkSumC = LoopJ + CArr[LoopI];
                if (wkSumC > T) continue;

                //満足度の和を求める
                if (SumVArr[LoopJ] == null) continue;
                int wkSumV = SumVArr[LoopJ].Value + VArr[LoopI];

                //満足度合計での最大の満足度を更新可能かを判定
                if (SumVArr[wkSumC] == null
                 || SumVArr[wkSumC] < wkSumV) {
                    SumVArr[wkSumC] = wkSumV;
                }
            }

            //同じアトラクションに乗った場合は、満足度は半分
            VArr[LoopI] /= 2;
            KasanValue = (VArr[LoopI] == 0 ? 1 : 0);
        }

        Console.WriteLine(SumVArr.Max(X => X ?? 0));
    }
}
0