From 07db60b85ea7a78ba94e3d048e17bbc49d7369a2 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 24 Sep 2020 18:47:06 +0800 Subject: [PATCH] P2676 [USACO07DEC] Bookshelf B R38819026 --- problem/P2676/P2676.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 problem/P2676/P2676.cpp diff --git a/problem/P2676/P2676.cpp b/problem/P2676/P2676.cpp new file mode 100644 index 00000000..94c62d7e --- /dev/null +++ b/problem/P2676/P2676.cpp @@ -0,0 +1,19 @@ +// R38819026 + +#include + +using namespace std; + +int main() { + int n, h[20005], b, sum=0, i; + cin >> n >> b; + for(i = 0 ; i < n ; i++) { + cin >> h[i]; + } + sort(h, h+n); + while(sum < b) { + sum += h[--i]; + } + cout << n-i << endl; + return 0; +}