Files
python/GESP/Level6/666.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

35 lines
694 B
C++

<<<<<<< HEAD
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int v[N], w[N];
int n, L;
int ans = INT_MAX;
int f[N][N];
int main() {
cin >> n >> L;
for (int i = 1; i <= n; i++)
cin >> v[i] >> w[i];
for (int i = 1; i <= n; i++)
for (int j = 0; j <= L; j++) {
f[i][j] = f[i - 1][j];
if (j >= v[i])
f[i][j] = max(f[i][j], f[i - 1][j - v[i]] + w[i]);
}
for (int j = 0; j <= L; j++) {
if (f[n][j] >= L) {
ans = j;
break;
}
}
if (ans < INT_MAX)
cout << ans << endl;
else
cout << "no solution" << endl;
return 0;
}
=======
>>>>>>> 13071b821300647688be50739c7b6b190b603339