Submission #1689557


Source Code Expand

#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


long long N, A, B, h[111111];


bool check(int c)
{
  int cc = 0;

  for (int i = 0; i < N; i ++) {
    if (h[i] < c * B)
        break;

    if (A == B) {
      if (h[i] > c * B)
        return false;
    }
    else {
      cc += (h[i] - c * B + A - B - 1) / (A - B);
    
      if (cc > c)
        return false;
    }
  }

  return true;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> h[i];

  std::sort(h, h + N, std::greater<int>());

  long long l = -1, u = 1000000000;

  while (u - l > 1) {
    long long m = (l + u) / 2;

    (check(m) ? u : l) = m;
  }

  std::cout << u << std::endl;

  return 0;
}

Submission Info

Submission Time
Task D - Widespread
User agw
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1317 Byte
Status AC
Exec Time 41 ms
Memory 1024 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 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 13 ms 1024 KB
b06 AC 30 ms 1024 KB
b07 AC 23 ms 1024 KB
b08 AC 24 ms 1024 KB
b09 AC 17 ms 1024 KB
b10 AC 18 ms 1024 KB
b11 AC 18 ms 1024 KB
b12 AC 18 ms 1024 KB
b13 AC 41 ms 1024 KB