結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー nanophoto12nanophoto12
提出日時 2014-11-17 23:07:52
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 974 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 105,524 KB
実行使用メモリ 49,092 KB
最終ジャッジ日時 2023-08-30 20:30:50
合計ジャッジ時間 10,093 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 236 ms
49,092 KB
testcase_01 AC 66 ms
23,420 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

internal class Program
{
    public static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var ls = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var k = long.Parse(Console.ReadLine());

        double minValue = 0;
        double maxValue = ls.Max();

        while (maxValue - minValue > 1e-13)
        {
            double mid = (minValue + maxValue)/2d;
            var sum = CalculateSum(n, ls, mid);
            if (sum >= k)
            {
                minValue = mid;
            }
            else
            {
                maxValue = mid;
            }
        }
        Console.WriteLine(minValue);
    }

    private static long CalculateSum(long n, long[] ls, double mid)
    {
        long sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += (long)(ls[i]/mid);
        }
        return sum;
    }
}
0