We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 88e9371 commit 5d97e01Copy full SHA for 5d97e01
kick-start/2020-A-A.cpp
@@ -0,0 +1,35 @@
1
+#include<bits/stdc++.h>
2
+
3
+using namespace std;
4
5
6
7
+void solve(){
8
+ int N,B;
9
+ cin >> N >> B;
10
+ vector<int> house(N,0);
11
+ for(int i=0 ; i < N ; ++i)
12
+ cin >> house[i];
13
+ sort(house.begin(), house.end());
14
+ int ans =0;
15
+ for (int i=0 ; i< N ; ++i)
16
+ {
17
+ if(B < house[i])
18
+ break;
19
+ ans ++;
20
+ B -= house[i];
21
+ }
22
+ cout << ans << "\n";
23
+}
24
25
+int main(){
26
+ int T;
27
+ cin >> T;
28
29
+ for(int t =1 ; t <= T ; ++ t){
30
+ cout << "Case #"<<t<<": ";
31
32
+ solve();
33
34
+ return 0;
35
0 commit comments