'commit'
This commit is contained in:
34
GESP/Level6/666.cpp
Normal file
34
GESP/Level6/666.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
<<<<<<< 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
|
||||
Reference in New Issue
Block a user