diff --git a/MarkAndToys.cpp b/MarkAndToys.cpp new file mode 100644 index 0000000..ba17c2b --- /dev/null +++ b/MarkAndToys.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include +using namespace std; + + + +int main() +{ + long long n, k; cin >> n >> k; + vector prices; + for(int i = 0; i < n; i++) + { + int p; cin >> p; + prices.push_back(p); + } + + int answer = 0; + + // Write the code for computing the final answer using n,k,prices + sort(prices.begin(), prices.end()); + + int i = 0; + + while(i < n){ + if(k < prices[i]){ + break; + } + k = k - prices[i]; + answer++; + i++; + } + + cout << answer << endl; + + return 0; +}