結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 720 ms
23,680 KB
testcase_01 AC 26 ms
18,560 KB
testcase_02 AC 293 ms
23,072 KB
testcase_03 AC 535 ms
23,424 KB
testcase_04 AC 587 ms
23,552 KB
testcase_05 AC 583 ms
23,552 KB
testcase_06 AC 562 ms
23,808 KB
testcase_07 AC 737 ms
23,680 KB
testcase_08 AC 737 ms
23,808 KB
testcase_09 AC 708 ms
23,552 KB
testcase_10 AC 527 ms
23,552 KB
testcase_11 AC 558 ms
23,552 KB
testcase_12 AC 498 ms
23,296 KB
testcase_13 AC 672 ms
23,552 KB
testcase_14 AC 699 ms
23,680 KB
testcase_15 AC 610 ms
23,552 KB
testcase_16 AC 524 ms
23,552 KB
testcase_17 AC 518 ms
23,680 KB
testcase_18 AC 504 ms
23,680 KB
testcase_19 AC 667 ms
23,680 KB
testcase_20 AC 665 ms
23,552 KB
testcase_21 AC 664 ms
23,680 KB
testcase_22 AC 458 ms
23,424 KB
testcase_23 AC 481 ms
23,424 KB
testcase_24 AC 26 ms
18,944 KB
testcase_25 AC 42 ms
20,864 KB
testcase_26 AC 32 ms
19,456 KB
testcase_27 AC 30 ms
19,328 KB
testcase_28 AC 141 ms
22,824 KB
testcase_29 AC 85 ms
23,036 KB
testcase_30 AC 43 ms
21,120 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