結果
| 問題 |
No.453 製薬会社
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-12-09 12:58:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 2,392 bytes |
| コンパイル時間 | 788 ms |
| コンパイル使用メモリ | 115,948 KB |
| 実行使用メモリ | 29,564 KB |
| 最終ジャッジ日時 | 2024-11-28 16:17:25 |
| 合計ジャッジ時間 | 1,999 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
public class Program
{
public void Proc() {
Reader.IsDebug = false;
decimal[] inpt = Reader.ReadLine().Split(' ').Select(a=>decimal.Parse(a)).ToArray();
C = inpt[0] * 2800;
D = inpt[1] * 2800;
decimal aCount = GetACount(0, Math.Min(C/21, D/7));
decimal ans = this.GetKingaku(aCount);
Console.WriteLine(ans);
}
private decimal C;
private decimal D;
private decimal GetACount(decimal min, decimal max) {
if(max-min < 0.00000000001m / 28) {
return Math.Round(min, 8);
}
decimal idx1 = min+((max-min)/3);
decimal idx2 = max-((max-min)/3);
decimal valMin = GetKingaku(min);
decimal val1 = GetKingaku(idx1);
decimal val2 = GetKingaku(idx2);
decimal valMax = GetKingaku(max);
decimal mx = new decimal[]{valMin, val1, val2, valMax}.Max();
if(valMin == mx) {
return GetACount(min, idx1);
} else if(valMax == mx) {
return GetACount(idx2, max);
} else if(val1 == mx) {
return GetACount(min, idx2);
} else {
return GetACount(idx2, max);
}
}
private decimal GetKingaku(decimal aCount) {
/*
・製品Aを作るには1kgあたり薬品Cが34kg、薬品Dが14kg必要である。
・製品Bを作るには1kgあたり薬品Cが27kg、薬品Dが57kg必要である。
*/
decimal nokoriC = this.C - (3*7*aCount);
decimal nokoriD = this.D - (1*7*aCount);
decimal bCount = Math.Min(nokoriC / (2*4), nokoriD / (5*4));
return aCount * 10 + bCount * 20;
}
public class Reader {
public static bool IsDebug = true;
private static System.IO.StringReader SReader;
private static string InitText = @"
5 6
";
public static string ReadLine() {
if(IsDebug) {
if(SReader == null) {
SReader = new System.IO.StringReader(InitText.Trim());
}
return SReader.ReadLine();
} else {
return Console.ReadLine();
}
}
}
public static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
14番