/* -*- coding: utf-8 -*- * * 2232.cc: No.2232 Miser's Gift - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_W = 100000; /* typedef */ /* global variables */ int ws[MAX_N], vs[MAX_N], dp[MAX_W + 1]; /* subroutines */ inline void setmax(int &a, int b) { if (a < b) a = b; } /* main */ int main() { int n, w; scanf("%d%d", &n, &w); for (int i = 0; i < n; i++) scanf("%d%d", ws + i, vs + i); fill(dp, dp + w + 1, -1); dp[0] = 0; for (int i = 0; i < n; i++) for (int j = w - ws[i]; j >= 0; j--) if (dp[j] >= 0) setmax(dp[j + ws[i]], dp[j] + vs[i]); for (int i = 0; i < w; i++) setmax(dp[i + 1], dp[i]); for (int x = 1; x <= w; x++) { printf("%d\n", dp[w] - dp[w - x] + 1); } return 0; }