-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1106_호텔.cpp
More file actions
45 lines (36 loc) · 728 Bytes
/
1106_호텔.cpp
File metadata and controls
45 lines (36 loc) · 728 Bytes
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
43
44
45
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
vector<pair<int, int> > vp;
int c, n;
int result = 0;
#define MAX_DP 100001
int dp[MAX_DP] = {
// 비용으로 얻을 수 있는 회원 수 DP
0,
};
int main() {
cin >> c >> n;
for (int i = 0; i < n; i++) {
int cost, person;
cin >> cost >> person;
vp.push_back(make_pair(cost, person));
}
for (int i = 0; i < MAX_DP; i++) {
for (int j = 0; j < n; j++) {
int index = i - vp[j].first;
if (index < 0) {
continue;
}
dp[i] = max(dp[i], dp[index] + vp[j].second);
}
if (dp[i] >= c) {
cout << i;
break;
}
}
return 0;
}