Submission #9789970


Source Code Expand

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using static System.Console;
    namespace AtCoder.ARC075
    {
        class Widespread
        {
            static public void Main()
            {
                var nab = ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
                var n = nab[0]; var a = nab[1]; var b = nab[2];
                var healthes = new int[n].Select(i => int.Parse(ReadLine().Trim())).ToArray();
                var max = healthes.Max();
                Func<int, bool> func = (count => IsWinnable(a, b, healthes, count));
                var res = BinSearch(func, max / a + 1, (max + b - 1)/ b);
                WriteLine(res);
            }
            static bool IsWinnable(int a, int b, int[] monster, int count)
            {
                return monster.Where(h => h > b * count).Select(h => (h - b * count + (a - b - 1)) / (a - b) ).Sum() <= count;
            }
            static int BinSearch(Func<int, bool> func, int from, int to)
            {
                if (from >= to) return from;
                else {
                    var mid =(from + to) / 2;
                    if (func(mid)) return BinSearch(func, from, mid);
                    else return BinSearch(func, mid + 1, to);
                }
            }
        }
    }

Submission Info

Submission Time
Task D - Widespread
User yudedako
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1433 Byte
Status RE
Exec Time 108 ms
Memory 19164 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 10
RE × 3
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 26 ms 9300 KB
a02 AC 25 ms 9300 KB
a03 AC 25 ms 9428 KB
b04 AC 24 ms 13396 KB
b05 AC 73 ms 17564 KB
b06 RE 73 ms 17372 KB
b07 AC 101 ms 17564 KB
b08 AC 100 ms 15068 KB
b09 RE 72 ms 17372 KB
b10 RE 74 ms 17372 KB
b11 AC 87 ms 17116 KB
b12 AC 85 ms 19164 KB
b13 AC 108 ms 17116 KB