Submission #9790000
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, max / b + 1); 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 - 1LL) / (a - b) + 1).Sum() <= count; } static int BinSearch(Func<int, bool> func, int from, int to) { if (from >= to) return from; else { var mid = to - (to - from + 1) / 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 | 400 |
Code Size | 1291 Byte |
Status | AC |
Exec Time | 160 ms |
Memory | 19164 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 27 ms | 13524 KB |
a02 | AC | 26 ms | 11476 KB |
a03 | AC | 27 ms | 13524 KB |
b04 | AC | 26 ms | 9300 KB |
b05 | AC | 78 ms | 15068 KB |
b06 | AC | 160 ms | 17116 KB |
b07 | AC | 111 ms | 19164 KB |
b08 | AC | 111 ms | 17116 KB |
b09 | AC | 90 ms | 19164 KB |
b10 | AC | 84 ms | 19164 KB |
b11 | AC | 89 ms | 17564 KB |
b12 | AC | 89 ms | 17116 KB |
b13 | AC | 122 ms | 17116 KB |