結果

問題 No.472 平均順位
ユーザー k3079kk3079k
提出日時 2019-09-12 15:24:47
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
実行時間 -
コード長 2,027 bytes
コンパイル時間 1,021 ms
コンパイル使用メモリ 72,132 KB
実行使用メモリ 394,412 KB
最終ジャッジ日時 2023-09-15 14:13:49
合計ジャッジ時間 10,158 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
30,264 KB
testcase_01 AC 66 ms
25,944 KB
testcase_02 AC 65 ms
23,800 KB
testcase_03 AC 65 ms
23,856 KB
testcase_04 AC 68 ms
23,808 KB
testcase_05 AC 66 ms
23,992 KB
testcase_06 AC 66 ms
23,868 KB
testcase_07 AC 74 ms
26,116 KB
testcase_08 AC 163 ms
36,376 KB
testcase_09 AC 519 ms
85,948 KB
testcase_10 AC 336 ms
61,932 KB
testcase_11 AC 1,484 ms
219,420 KB
testcase_12 AC 1,052 ms
162,168 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

namespace Test01
{
    class Program
    {
        const int INF = 1000000009;
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = input[0];
            int P = input[1];

            int[,] c = new int[N + 1, 4];
            for(int i = 1; i <= N; i++)
            {
                input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                for(int j = 0; j < 4; j++)
                {
                    if (j == 3) c[i, j] = 1;
                    else c[i, j] = input[j];
                }
            }
           
            double[,,] dp = new double[P + 1, N + 1, 4];          
            for(int p = 0; p <= P; p++)
            {
                for(int i = 0; i <= N; i++)
                {
                    for(int j = 0; j < 4; j++)
                    {
                        if (p < j) dp[p, i, j] = INF;
                    }
                }
            }

            //p問解いた
            for(int p = 0; p <= P; p++)
            {
                //i番目のコンテスト
                for(int i = 1; i <= N; i++)
                {
                    //i番目のコンテストでj解いた
                    for(int j = 0; j <= 3; j++)
                    {
                        if (p < j) continue;
                        double min = Math.Min(dp[p - j, i - 1, 0], dp[p - j, i - 1, 1]);
                        min = Math.Min(min, dp[p - j, i - 1, 2]);
                        min = Math.Min(min, dp[p - j, i - 1, 3]);
                        dp[p, i, j] = (min * (i - 1) + c[i, j]) / i;
                    }
                }
            }

            double ans;
            ans = Math.Min(dp[P, N, 0], dp[P, N, 1]);
            ans = Math.Min(ans, dp[P, N, 2]);
            ans = Math.Min(ans, dp[P, N, 3]);
            Console.WriteLine(ans);
        }
    }
}
0