Last active
April 17, 2020 09:16
-
-
Save atiqueahmedziad/e26b6062deb86f37d2c38069395f8184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
struct NBA { | |
int n,b; | |
int arr[1000000]; | |
}; | |
int main() { | |
int t; | |
cin >> t; | |
struct NBA nba_arr[t]; | |
for (int i = 0; i < t; i++) { | |
cin >> nba_arr[i].n >> nba_arr[i].b; | |
for (int j = 0; j <nba_arr[i].n; j++) { | |
cin >> nba_arr[i].arr[j]; | |
} | |
} | |
for (int i = 0; i < t; i++) { | |
sort(nba_arr[i].arr, nba_arr[i].arr+nba_arr[i].n); | |
int num = 0; | |
for (int j = 0; j <nba_arr[i].n; j++){ | |
if(nba_arr[i].b < nba_arr[i].arr[j]){ | |
break; | |
} | |
num++; | |
nba_arr[i].b -= nba_arr[i].arr[j]; | |
} | |
cout << "Case #" << i+1 << ": " << num << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment