結果

問題 No.472 平均順位
ユーザー mbanmban
提出日時 2017-07-17 23:37:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 914 ms / 2,000 ms
コード長 1,860 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 113,220 KB
実行使用メモリ 50,520 KB
最終ジャッジ日時 2024-04-17 00:08:05
合計ジャッジ時間 5,553 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,772 KB
testcase_01 AC 29 ms
27,684 KB
testcase_02 AC 29 ms
27,684 KB
testcase_03 AC 29 ms
27,912 KB
testcase_04 AC 29 ms
23,732 KB
testcase_05 AC 28 ms
25,644 KB
testcase_06 AC 30 ms
27,912 KB
testcase_07 AC 30 ms
25,904 KB
testcase_08 AC 32 ms
25,772 KB
testcase_09 AC 61 ms
33,068 KB
testcase_10 AC 49 ms
29,836 KB
testcase_11 AC 124 ms
50,520 KB
testcase_12 AC 98 ms
46,580 KB
testcase_13 AC 298 ms
49,544 KB
testcase_14 AC 788 ms
44,900 KB
testcase_15 AC 308 ms
49,800 KB
testcase_16 AC 873 ms
43,468 KB
testcase_17 AC 914 ms
41,564 KB
testcase_18 AC 85 ms
44,788 KB
testcase_19 AC 145 ms
32,084 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, P;
    private int[] A, B, C;

    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        P = int.Parse(line[1]);
        A = new int[N];
        B = new int[N];
        C = new int[N];
        for (int i = 0; i < N; i++)
        {
            line = Console.ReadLine().Split(' ');
            A[i] = int.Parse(line[0]);
            B[i] = int.Parse(line[1]);
            C[i] = int.Parse(line[2]);
        }
    }

    public void Solve()
    {
        Scan();
        var dp = (new int[P + 1]).Select(i => int.MaxValue).ToArray();
        for (int i = 0; i <= P; i++)
        {
            dp[i] = int.MaxValue;
        }
        dp[0] = 0;
        for (int i = 0; i < N; i++)
        {
            var next = new int[P + 1];
            for (int j = 0; j <= P; j++)
            {
                next[j] = int.MaxValue;
            }
            for (int j = P; j >= 0; j--)
            {
                if (dp[j] != int.MaxValue)
                {
                    next[j + 0] = Math.Min(next[j + 0], dp[j] + A[i]);
                    if (j + 1 <= P)
                        next[j + 1] = Math.Min(next[j + 1], dp[j] + B[i]);
                    if (j + 2 <= P)
                        next[j + 2] = Math.Min(next[j + 2], dp[j] + C[i]);
                    if (j + 3 <= P)
                        next[j + 3] = Math.Min(next[j + 3], dp[j] + 1);
                }
            }
            dp = next;
        }
        Console.WriteLine((double)dp[P] / N);
    }
}
0