func_code_string: #include <bits/stdc++.h>   int dp[51 * 10001];   int main(void) {     int n, d, a, sum, i, j;     while (scanf( %d%d , &n, &d) != EOF) {       sum = 0;       memset(dp, 0, sizeof(dp));       dp[0] = 1;       for (i = 0; i < n; i++) {         scanf( %d , &a);         sum += a;         for (j = sum; j >= a; j--) {           if (dp[j - a] == 1) dp[j] = 1;         }       }       int k = 0;       int ans = 0;       while (true) {         i = k + d;         while (dp[i] == 0 && i > k) i--;         if (k == i) break;         k = i;         ans++;       }       printf( %d %d n , k, ans);     }     return 0;   }   