結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-03-05 02:19:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,801 bytes
コンパイル時間 1,010 ms
コンパイル使用メモリ 114,084 KB
実行使用メモリ 33,836 KB
最終ジャッジ日時 2024-06-24 08:17:10
合計ジャッジ時間 14,220 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
25,004 KB
testcase_02 AC 234 ms
29,060 KB
testcase_03 AC 418 ms
31,244 KB
testcase_04 AC 439 ms
31,672 KB
testcase_05 AC 430 ms
30,000 KB
testcase_06 WA -
testcase_07 AC 577 ms
27,924 KB
testcase_08 AC 573 ms
29,700 KB
testcase_09 WA -
testcase_10 AC 383 ms
31,784 KB
testcase_11 AC 409 ms
31,664 KB
testcase_12 WA -
testcase_13 AC 528 ms
31,864 KB
testcase_14 AC 547 ms
31,996 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 26 ms
25,140 KB
testcase_25 AC 37 ms
26,728 KB
testcase_26 AC 31 ms
26,796 KB
testcase_27 AC 29 ms
24,932 KB
testcase_28 AC 118 ms
30,984 KB
testcase_29 AC 73 ms
31,184 KB
testcase_30 AC 39 ms
27,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Numerics;
using sc = Scanner;
class Program
{
    static void Main(string[] args)
    {
        Solver solver = new Solver();
        solver.Solve();
#if DEBUG
        System.Console.WriteLine("続行するには何かキーを押してください...");
        System.Console.ReadKey();
#endif

    }
}
/// <summary>
/// Java風のスキャナー,自作(某最速の人を参考)
/// </summary>
public static class Scanner
{
    public static string NextString()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return tmp;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return int.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return long.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return double.Parse(tmp);
    }

    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static double[] NextDoubleArray()
    {
        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
#endregion ZIPPER

public class Solver
{
#region IGNORE_ME
    public Solver()
    {
        //こんすとらくたん きにしなくてよろしい
    }
#endregion IGNORE_ME

#region FIELD

#endregion FIELD

    public void Solve()
    {
        int n = sc.NextInt();
        long[] l = new long[n];
        for (int i = 0; i < n; i++)
        {
            l[i] = sc.NextLong();
        }
        long k = sc.NextLong();
        double eps = 1e-9;
        double low = 0;
        double mid = 1;
        double hi = 2 * 10000 + 1000; // seiyaku ni yoru max yori tyotto over
        while (hi >low + eps && hi > low*(1+eps))
        {
            mid = (low + hi) / 2;
            if (canCut(l,mid,k))
            {
                low = mid;
            }
            else
            {
                hi = mid;
            }
        
        }
        Console.WriteLine((low+hi)/2);
#if DEBUG
        Console.WriteLine("");//local check
#endif
    }
    /// <summary>
    ///ipponnatari s no nagasa de k hon kiretu
    /// </summary>
    /// <param name="l"></param>
    /// <param name="s"></param>
    /// <returns></returns>
    bool canCut(long[] l,double s, long k)
    {
        long countOfCut = 0;
        for (int i = 0; i < l.Length; i++)
        {
            countOfCut += (long)Math.Floor((double)l[i]/s);
        }
        return countOfCut >= k ? true : false;
    }

}
0