We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acd1ec1 commit cde53abCopy full SHA for cde53ab
weekly/week02/BOJ_15486_퇴사2/whqtker.cpp
@@ -0,0 +1,27 @@
1
+#include <iostream>
2
+#include <algorithm>
3
+
4
+using namespace std;
5
6
+int dp[1500051];
7
+pair<int, int> consult[1500001]; // consult[i] = { x, y } : i일의 상담은 x일이 걸리며 수익은 y
8
9
+int main() {
10
+ int n;
11
+ cin >> n;
12
+ for (int i = 1; i <= n; i++) {
13
+ int x, y;
14
+ cin >> x >> y;
15
+ consult[i] = { x, y };
16
+ }
17
18
19
+ dp[i + 1] = max(dp[i + 1], dp[i]);
20
21
+ if (i + consult[i].first <= n + 1) {
22
+ dp[i + consult[i].first] = max(dp[i + consult[i].first], dp[i] + consult[i].second);
23
24
25
26
+ cout << dp[n + 1] << "\n";
27
+}
0 commit comments