結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-03-05 02:23:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 719 ms / 5,000 ms
コード長 4,754 bytes
コンパイル時間 2,712 ms
コンパイル使用メモリ 113,948 KB
実行使用メモリ 32,004 KB
最終ジャッジ日時 2024-04-25 23:20:21
合計ジャッジ時間 18,125 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 680 ms
29,696 KB
testcase_01 AC 25 ms
25,128 KB
testcase_02 AC 278 ms
29,064 KB
testcase_03 AC 499 ms
27,400 KB
testcase_04 AC 548 ms
31,920 KB
testcase_05 AC 551 ms
29,748 KB
testcase_06 AC 534 ms
29,740 KB
testcase_07 AC 697 ms
31,864 KB
testcase_08 AC 719 ms
31,868 KB
testcase_09 AC 693 ms
32,004 KB
testcase_10 AC 500 ms
29,636 KB
testcase_11 AC 542 ms
30,016 KB
testcase_12 AC 468 ms
31,784 KB
testcase_13 AC 654 ms
29,824 KB
testcase_14 AC 677 ms
29,564 KB
testcase_15 AC 581 ms
31,616 KB
testcase_16 AC 506 ms
29,876 KB
testcase_17 AC 504 ms
29,740 KB
testcase_18 AC 477 ms
31,804 KB
testcase_19 AC 635 ms
27,908 KB
testcase_20 AC 637 ms
31,984 KB
testcase_21 AC 637 ms
29,676 KB
testcase_22 AC 435 ms
29,624 KB
testcase_23 AC 462 ms
30,016 KB
testcase_24 AC 25 ms
24,992 KB
testcase_25 AC 40 ms
25,008 KB
testcase_26 AC 31 ms
25,064 KB
testcase_27 AC 27 ms
23,220 KB
testcase_28 AC 137 ms
31,112 KB
testcase_29 AC 77 ms
28,996 KB
testcase_30 AC 39 ms
26,956 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*1e15; //
        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