結果

問題 No.453 製薬会社
ユーザー 14番14番
提出日時 2016-12-09 12:58:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 2,392 bytes
コンパイル時間 4,548 ms
コンパイル使用メモリ 110,820 KB
実行使用メモリ 24,216 KB
最終ジャッジ日時 2023-08-19 03:10:12
合計ジャッジ時間 6,801 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
24,072 KB
testcase_01 AC 74 ms
21,960 KB
testcase_02 AC 73 ms
22,128 KB
testcase_03 AC 76 ms
24,216 KB
testcase_04 AC 75 ms
22,148 KB
testcase_05 AC 74 ms
21,988 KB
testcase_06 AC 72 ms
23,980 KB
testcase_07 AC 72 ms
21,904 KB
testcase_08 AC 73 ms
24,032 KB
testcase_09 AC 74 ms
22,168 KB
testcase_10 AC 72 ms
22,056 KB
testcase_11 AC 73 ms
23,928 KB
testcase_12 AC 72 ms
19,940 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.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();
    }
}
0