#include #include int cmp_int (const void *ap, const void *bp) { int a = *(int *)ap; int b = *(int *)bp; if (a < b) { return -1; } if (a > b) { return 1; } return 0; } int main () { int n = 0; int k = 0; int a[200000] = {}; int res = 0; int ans = 0; res = scanf("%d", &n); res = scanf("%d", &k); for (int i = 0; i < n; i++) { res = scanf("%d", a+i); } qsort(a, n, sizeof(int), cmp_int); for (int i = 0; i < n; i++) { if (a[i] <= k) { ans++; k -= a[i]; } } printf("%d %d\n", ans, k); return 0; }