Submission #4643331


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 063 D / Link: http://abc063.contest.atcoder.jp/tasks/abc063_d  ----- */


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	LL N, A, B; cin >> N >> A >> B;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	auto f = [&A,&B,&N](LL x, VL a) {
		FOR(i, 0, N) {
			a[i] -= x * B;
		}
		LL needx = 0;
		FOR(i, 0, N) {
			if (a[i] > 0)needx += (a[i] - 1 + (A - B)) / (A - B);
		}

		return needx <= x;
	};
	LL L = 0, R = 1e9;
	while (R - L > 1) {
		LL mid = (L + R) / 2;
		if (f(mid,a)) {
			R = mid;
		}
		else {
			L = mid;
		}
	}
	LL ans = R;
	
	cout << (ans) << "\n";

	return 0;
}

Submission Info

Submission Time
Task D - Widespread
User Yang33
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1647 Byte
Status AC
Exec Time 46 ms
Memory 1792 KiB

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 KiB
a02 AC 1 ms 256 KiB
a03 AC 1 ms 256 KiB
b04 AC 1 ms 256 KiB
b05 AC 18 ms 1792 KiB
b06 AC 46 ms 1792 KiB
b07 AC 29 ms 1792 KiB
b08 AC 25 ms 1792 KiB
b09 AC 19 ms 1792 KiB
b10 AC 19 ms 1792 KiB
b11 AC 19 ms 1792 KiB
b12 AC 21 ms 1792 KiB
b13 AC 37 ms 1792 KiB