結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー picares9ue
提出日時 2017-06-08 17:41:26
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,138 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 112,636 KB
実行使用メモリ 54,848 KB
最終ジャッジ日時 2025-03-03 10:42:51
合計ジャッジ時間 9,631 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.IO;
using System.Diagnostics;

class Program{
    static void Main(){
        var watch = new Stopwatch();
        TextReader reader;
        string filename = "";
        if(filename.Length!=0)reader = new StreamReader(filename);
        else reader = Console.In;
        var n = Int64.Parse(reader.ReadLine());
        long[] lis = reader.ReadLine().Split().Select(Int64.Parse).ToArray();
        var k = Int64.Parse(reader.ReadLine());

        watch.Start();
        double left = 0;
        double right = 10e9;
        /*誤差の吸収がめんどくさいので回数決め打ちループ */
        int cnt = 0;
        while(left<right && cnt<100){
            var mid = (left+right)/2;
            var v = Func(mid, lis, n);
            if(v > k) left = mid;
            else right = mid; 
            cnt++;
        }
        Console.WriteLine(right);
    }

    static long Func(double p, long[] lis, long n){
        long ans = 0;
        for(long i=0; i<n; i++){
            ans+=(long)((double)lis[i]/p);
        }
        return ans;
    }
}
0