Submission #2924972


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	#ifdef LOCAL_DEFINE
	freopen("input.txt", "rt", stdin);
	#endif

	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	sort(a.begin(), a.end(), greater<int>());
	
	int sum = 0, ans = 0;
	
	for(auto e : a) if(sum < k) sum += e, ans++;

	cout << (sum >= k ? ans : -1 ) << endl;

	#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s. \n";
	#endif 

	return 0;
}

Submission Info

Submission Time
Task A - Credits
User Impulse
Language C++14 (GCC 5.4.1)
Score 100
Code Size 568 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
Set Name Test Cases
All corner_10, corner_11, corner_12, corner_13, max_14, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, sample_00, sample_01, sample_02
Case Name Status Exec Time Memory
corner_10 AC 1 ms 256 KB
corner_11 AC 1 ms 256 KB
corner_12 AC 1 ms 256 KB
corner_13 AC 1 ms 256 KB
max_14 AC 1 ms 256 KB
random_00 AC 1 ms 256 KB
random_01 AC 1 ms 256 KB
random_02 AC 1 ms 256 KB
random_03 AC 1 ms 256 KB
random_04 AC 1 ms 256 KB
random_05 AC 1 ms 256 KB
random_06 AC 1 ms 256 KB
random_07 AC 1 ms 256 KB
random_08 AC 1 ms 256 KB
random_09 AC 1 ms 256 KB
sample_00 AC 1 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB