Skip to content

Commit

Permalink
13109 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
ksaveljev committed Feb 21, 2018
1 parent 083d9cf commit f1dd467
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions 13109.cpp
@@ -0,0 +1,38 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i, b, n) for (int i = b; i < n; i++)
#define rep(i, n) REP(i, 0, n)

int main(void) {
int t, m, w, e;

cin >> t;

while (t--) {
cin >> m >> w;
vector<int> weights(m);

rep (i, m) {
cin >> e;
weights[i] = e;
}

sort(weights.begin(), weights.end());

int count = 0;
int sum = 0;

rep (i, m) {
if (sum + weights[i] > w) break;
sum += weights[i];
count += 1;
}

cout << count << endl;
}

return 0;
}

0 comments on commit f1dd467

Please sign in to comment.