1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include <iostream>
#include <vector>
#define MAXX 101
#define MAXM 100*100+1
using namespace std;
int dp[MAXM];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
//앱의 수, 확보해야하는 메모리 양
int mem[MAXX] = { 0 }, cost[MAXX] = { 0 };
int total = 0;
for (int i = 0; i < n; i++) {
cin >> mem[i]; //각 앱 당 메모리양
}
for (int i = 0; i < n; i++) {
cin >> cost[i];
total += cost[i];
}
int ans = 98765421;
for (int i = 0; i < n; i++) {
for (int j = total; j >= cost[i]; j--) {
dp[j] = max(dp[j], dp[j - cost[i]] + mem[i]);
if (dp[j] >= m) ans = min(ans, j);
}
}
/*for (int i = 0; i <= total; i++) {
cout << i << " " << dp[i] << '\n';
}*/
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
BOJ/C++