#include<cstdio> #include<algorithm> using namespace std; int main() { int tc,m,max_w,w[100000],sum; scanf("%d",&tc); while (tc--) { scanf("%d%d",&m,&max_w); for (int i=0;i<m;i++) scanf("%d",&w[i]); sort(w,w+m); sum=0; int flag=1; for (int i=0;i<m;i++) { sum+=w[i]; if (sum>max_w) { printf("%d\n",i); flag=0; break; } } if (flag) printf("%d\n",m); } return 0; }
Sunday, July 17, 2016
UVA 13109 Solution
Unknown
Studying at Shahjalal University of Science and Technology, Sylhet.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment