From 5889f1bb0f6eb525769742e7c25adc8eb11a3ba3 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Fri, 26 Nov 2021 19:23:25 +0800 Subject: [PATCH] A - Divan and a Store https://codeforces.com/contest/1614/submission/136995472 --- CodeForces/1614/A/A.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CodeForces/1614/A/A.cpp diff --git a/CodeForces/1614/A/A.cpp b/CodeForces/1614/A/A.cpp new file mode 100644 index 00000000..56221f3a --- /dev/null +++ b/CodeForces/1614/A/A.cpp @@ -0,0 +1,28 @@ +#include + +using std::cin; +using std::cout; +using std::endl; + +int t, n, l, r, k, a[105]; + +int main() { + cin >> t; + while (t--) { + int ans = 0; + cin >> n >> l >> r >> k; + for (int i = 0; i < n; i++) { + cin >> a[i]; + } + std::sort(a, a + n); + for (int i = 0; i < n; i++) { + if (k < a[i]) break; + if (l <= a[i] && a[i] <= r) { + k -= a[i]; + ans++; + } + } + cout << ans << endl; + } + return 0; +}