Submission #1868006


Source Code Expand

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

const int N = 100005;

int n, h[N], A, B;
long long H[N];

bool check(int val) {
	for (int i = 1; i <= n; ++i) H[i] = h[i] - 1LL * val * B; // H[i]: long long
	long long cnt = 0;
	for (int i = 1; i <= n; ++i) if (H[i] > 0) {
		cnt += (H[i] + A - 1) / A;
	}
	return cnt <= val;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> A >> B;
	A -= B;
	for (int i = 1; i <= n; ++i) cin >> h[i];

	// use binary search optimal sum
	int l = 0, r = 1e9;
	while(l < r) {
		int mid = ((l + r) >> 1);
		if (check(mid)) r = mid; else l = mid + 1;
	}
	cout << l << endl;
}

Submission Info

Submission Time
Task D - Widespread
User cheater2k
Language C++14 (GCC 5.4.1)
Score 400
Code Size 659 Byte
Status AC
Exec Time 44 ms
Memory 1408 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 17 ms 1408 KB
b06 AC 44 ms 1408 KB
b07 AC 25 ms 1408 KB
b08 AC 24 ms 1408 KB
b09 AC 17 ms 1408 KB
b10 AC 15 ms 1408 KB
b11 AC 17 ms 1408 KB
b12 AC 18 ms 1408 KB
b13 AC 37 ms 1408 KB