Skip to content

Instantly share code, notes, and snippets.

@Luzhiled
Last active June 4, 2017 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luzhiled/392f7e9ebaef455e268eeda9d3de419a to your computer and use it in GitHub Desktop.
Save Luzhiled/392f7e9ebaef455e268eeda9d3de419a to your computer and use it in GitHub Desktop.
ARC075-D
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back
using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;
const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
vector<lint> h;
lint n;
lint a, b, d;
bool f(lint m) {
lint cnt = 0;
rep(i, n) {
lint H = h[i] - m * b;
if (H <= 0) continue;
cnt += (H + d - 1) / d;
}
return cnt <= m;
}
int main() {
cin >> n >> a >> b;
d = a - b;
lint s = 0;
rep(i, n) { h.pb(in()); chmax(s, h[i]); }
lint l = 0, r = s / b + 1000;
while (r - l > 1) {
lint m = (l + r) / 2;
if (f(m)) {
r = m;
} else {
l = m;
}
}
if (!f(l)) {
l = r;
}
cout << l << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment