結果
問題 | No.472 平均順位 |
ユーザー |
|
提出日時 | 2019-09-12 15:24:47 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,027 bytes |
コンパイル時間 | 5,513 ms |
コンパイル使用メモリ | 112,376 KB |
実行使用メモリ | 450,004 KB |
最終ジャッジ日時 | 2024-07-02 17:06:33 |
合計ジャッジ時間 | 8,791 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 MLE * 1 -- * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);}}}