結果
問題 |
No.37 遊園地のアトラクション
|
ユーザー |
![]() |
提出日時 | 2014-10-30 00:10:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,040 bytes |
コンパイル時間 | 2,115 ms |
コンパイル使用メモリ | 106,496 KB |
実行使用メモリ | 19,504 KB |
最終ジャッジ日時 | 2024-12-30 13:48:16 |
合計ジャッジ時間 | 3,173 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 WA * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Globalization; using System.Linq; class Program { public static void Main(string[] args) { var t = int.Parse(Console.ReadLine()); var n = int.Parse(Console.ReadLine()); var ci = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var vi = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); int[] dp = new int[t + 1]; int[,] counts = new int[t+ 1, n]; for (int dt = 1; dt <= t; dt++) { int next = -1; int maxIndex = -1; for (int k = 0; k < n; k++) { var current = 0; if (dt - ci[k] >= 0) { current = dp[dt - ci[k]] + (int) (vi[k]*Math.Pow(1/2d, counts[dt - ci[k], k])); } else { continue; } if(next < current) { next = current; maxIndex = k; } } if (next == - 1) { dp[dt] = dp[dt-1]; for (int i = 0; i < n; i++) { if (dt - ci[i] >= 0) { counts[dt, i] = counts[dt - ci[i], i]; } else { counts[dt, i] = 0; } } continue; } dp[dt] = next; for (int i = 0; i < n; i++) { if (dt - ci[i] >= 0) { counts[dt, i] = counts[dt - ci[i], i]; } else { counts[dt, i] = 0; } } counts[dt, maxIndex]++; } Console.WriteLine(dp[t].ToString(CultureInfo.InvariantCulture)); } }