結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-03-05 02:04:08
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,710 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 106,728 KB
実行使用メモリ 48,084 KB
最終ジャッジ日時 2023-09-06 13:27:43
合計ジャッジ時間 8,497 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 63 ms
22,612 KB
testcase_02 AC 113 ms
31,492 KB
testcase_03 AC 157 ms
42,044 KB
testcase_04 AC 190 ms
40,592 KB
testcase_05 AC 188 ms
42,372 KB
testcase_06 WA -
testcase_07 AC 186 ms
41,216 KB
testcase_08 AC 186 ms
45,332 KB
testcase_09 WA -
testcase_10 AC 181 ms
39,468 KB
testcase_11 AC 186 ms
41,868 KB
testcase_12 WA -
testcase_13 AC 182 ms
42,312 KB
testcase_14 AC 186 ms
42,760 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 64 ms
24,532 KB
testcase_25 AC 73 ms
23,000 KB
testcase_26 AC 71 ms
22,864 KB
testcase_27 AC 73 ms
24,716 KB
testcase_28 AC 89 ms
24,188 KB
testcase_29 AC 81 ms
25,876 KB
testcase_30 AC 75 ms
22,980 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 = sc.NextLongArray();
        long k = sc.NextLong();
        double eps = 1.0/1000000000;
        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)(l[i]/s);
        }
        return countOfCut >= k ? true : false;
    }

}
0