# include <bits/stdc++.h>
# define old_six \
ios::sync_with_stdio (0);\
\
cin.tie (0);\
\
cout.tie (0);
# define ffor(i,name) \
for (auto i = name.end (); i != name.end (); i ++)
# define iter(type) \
type :: iterator
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n, m, l, a[105], b[105], dp[1005];
int main () {
old_six
cin >> t;
while (t --) {
cin >> n >> m >> l;
fill (dp + 1, dp + l + 1, -1e9);
for (int i = 0; i < n; i ++)
cin >> a[i] >> b[i];
for (int i = 0; i < n; i ++)
for (int j = m; j; j --)
for (int k = l; k >= a[i]; k --)
dp[k] = max (dp[k], dp[k - a[i]] + b[i]);
cout << dp[l] << '\n';
}
return 0;
}
蒟蒻求助!HDU3496WA了
最新推荐文章于 2024-07-22 09:38:37 发布