Submission #2894299


Source Code Expand

n,a,b = gets.chomp.split(" ").map(&:to_i)
h = n.times.map{gets.to_i}
min = 1
max = h.inject(0){|r,i|r+(i+a-1)/a}
while min <= max
  mid = min+(max-min)/2
  ans = 0
  for i in 0..n-1
    ans += ([0,h[i]-b*mid].max+a-b-1)/(a-b)
  end
  if ans < mid
    max = mid-1
  elsif ans > mid
    min = mid+1
  else
    break
  end
end
for i in mid-1..mid+1
  ans = 0
  for j in 0..n-1
    ans += ([0,h[j]-b*i].max+a-b-1)/(a-b)
  end
  if ans <= i
    puts i
    exit
  end
end

Submission Info

Submission Time
Task D - Widespread
User koikotya
Language Ruby (2.3.3)
Score 400
Code Size 492 Byte
Status AC
Exec Time 1929 ms
Memory 3068 KB

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 7 ms 1788 KB
a02 AC 7 ms 1788 KB
a03 AC 7 ms 1788 KB
b04 AC 7 ms 1788 KB
b05 AC 830 ms 3068 KB
b06 AC 1929 ms 3068 KB
b07 AC 785 ms 3068 KB
b08 AC 825 ms 3068 KB
b09 AC 1898 ms 2996 KB
b10 AC 1785 ms 2996 KB
b11 AC 1459 ms 3068 KB
b12 AC 1235 ms 3068 KB
b13 AC 788 ms 2996 KB