Submission #7479064


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static int n, a, b;
    static int[] h;
    
    static bool enough(int times)
    {
	int c = (a - b);
	int t = 0;
	for (int i = 0; i < n; i++)
	{
	    int hr = h[i] - b*times;
	    if(hr > 0)
	    {
		t += (hr + c - 1) / c;
		if (t > times) return false;
	    }
	}
	return true;
    }
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0]; a = tmp[1]; b = tmp[2];
	h = new int[n];

	int hmax = 0;
	for (int i = 0; i < n; i++)
	    hmax = Math.Max(hmax, h[i] = int.Parse(ReadLine()));

	int l = 0, r = (hmax + b - 1) / b;
	int m = -1;
	while (l < r)
	{
	    m = (l + r) / 2;
	    //WriteLine($"{hmax} {l} {r} {m}");
	    if (enough(m)){ r = m; }
	    else { l = m + 1; }
	}
	WriteLine(r);
    }
}

Submission Info

Submission Time
Task D - Widespread
User unnohideyuki
Language C# (Mono 4.6.2.0)
Score 400
Code Size 1091 Byte
Status AC
Exec Time 77 ms
Memory 17872 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 13
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 AC 23 ms 11220 KiB
a02 AC 23 ms 9172 KiB
a03 AC 23 ms 11348 KiB
b04 AC 23 ms 11220 KiB
b05 AC 65 ms 17872 KiB
b06 AC 72 ms 15824 KiB
b07 AC 74 ms 17872 KiB
b08 AC 71 ms 15824 KiB
b09 AC 70 ms 15824 KiB
b10 AC 66 ms 13776 KiB
b11 AC 67 ms 15824 KiB
b12 AC 70 ms 15824 KiB
b13 AC 77 ms 15824 KiB