aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/ferris_wheel_1090.cpp
blob: f64b33b62367d46c5e850436b1219f3a45d7f14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	int n, x;
	std::cin >> n >> x;
	std::vector<int> a(n);
	for (int i = 0; i < n; i++)
		std::cin >> a[i];
	std::sort(a.begin(), a.end());
	size_t i{0}, j{a.size()-1}, s{0};
	for (; j > i; j--, s++)
		i += a[i] + a[j] <= x;
	if (i == j) s++;
	std::cout << s << "\n";
}

Generated with cgit - Back to sebastiano.tronto.net