Skip to content

Commit 5d97e01

Browse files
authored
Create 2020-A-A.cpp
1 parent 88e9371 commit 5d97e01

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

kick-start/2020-A-A.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)