Submission #9789950


Source Code Expand

#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main() {
	int n; long long int a, b; std::cin >> n >> a >> b;
	std::vector<int> monsters(n); for (auto& m : monsters) std::cin >> m;
	std::sort(monsters.begin(), monsters.end());
	int min = 1, max = 1000000000;
	while (min < max) {
		const auto mid = (min + max) >> 1;
		const auto can_defeat = std::distance(monsters.begin(), std::upper_bound(monsters.begin(), monsters.end(), mid * b));
		long long int count = 0;
		for (auto i = can_defeat; i < n; ++i) {
			count += (monsters[i] - mid * b + (a - b) - 1) / (a - b);
		}
		if (count > mid) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	std::cout << min << std::endl;
}

Submission Info

Submission Time
Task D - Widespread
User yudedako
Language C++14 (Clang 3.8.0)
Score 400
Code Size 1055 Byte
Status AC
Exec Time 142 ms
Memory 640 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 2 ms 384 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 111 ms 640 KB
b06 AC 142 ms 640 KB
b07 AC 120 ms 640 KB
b08 AC 120 ms 640 KB
b09 AC 119 ms 640 KB
b10 AC 117 ms 640 KB
b11 AC 118 ms 640 KB
b12 AC 118 ms 640 KB
b13 AC 139 ms 640 KB