aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/ferris_wheel_1090.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-07-06 19:08:08 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-07-06 19:08:08 +0200
commit96254947699986c59f0dc63d69fd4b76bd3ed43e (patch)
tree6c4dca945d7f7427c48be234d827fe4d33be02c5 /02_sorting_and_searching/ferris_wheel_1090.cpp
downloadcses-96254947699986c59f0dc63d69fd4b76bd3ed43e.tar.gz
cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.zip
Initial commit
Diffstat (limited to '02_sorting_and_searching/ferris_wheel_1090.cpp')
-rw-r--r--02_sorting_and_searching/ferris_wheel_1090.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/02_sorting_and_searching/ferris_wheel_1090.cpp b/02_sorting_and_searching/ferris_wheel_1090.cpp
new file mode 100644
index 0000000..f64b33b
--- /dev/null
+++ b/02_sorting_and_searching/ferris_wheel_1090.cpp
@@ -0,0 +1,17 @@
1#include <algorithm>
2#include <iostream>
3#include <vector>
4
5int main() {
6 int n, x;
7 std::cin >> n >> x;
8 std::vector<int> a(n);
9 for (int i = 0; i < n; i++)
10 std::cin >> a[i];
11 std::sort(a.begin(), a.end());
12 size_t i{0}, j{a.size()-1}, s{0};
13 for (; j > i; j--, s++)
14 i += a[i] + a[j] <= x;
15 if (i == j) s++;
16 std::cout << s << "\n";
17}

Generated with cgit - Back to sebastiano.tronto.net