diff --git "a/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/gyuhyeok99.cpp" "b/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/gyuhyeok99.cpp" new file mode 100644 index 0000000..ba05fbf --- /dev/null +++ "b/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/gyuhyeok99.cpp" @@ -0,0 +1,31 @@ +#include +#include + +using namespace std; + +int n, ret; +int arr[1500001][2]; +int dp[1500001]; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + cin >> n; + + for (int i = 0; i < n; i++) { + cin >> arr[i][0] >> arr[i][1]; + } + + for (int i = n - 1; i >= 0; i--) { + if (i + arr[i][0] <= n) { + dp[i] = max(dp[i + 1], arr[i][1] + dp[i + arr[i][0]]); + } else { + dp[i] = dp[i + 1]; + } + } + + cout << dp[0] << '\n'; + return 0; +} diff --git "a/weekly/week02/BOJ_1965_\354\203\201\354\236\220\353\204\243\352\270\260/gyuhyeok99.cpp" "b/weekly/week02/BOJ_1965_\354\203\201\354\236\220\353\204\243\352\270\260/gyuhyeok99.cpp" new file mode 100644 index 0000000..1b09deb --- /dev/null +++ "b/weekly/week02/BOJ_1965_\354\203\201\354\236\220\353\204\243\352\270\260/gyuhyeok99.cpp" @@ -0,0 +1,26 @@ +#include +#include + +using namespace std; + +int n, len, num; +int lis[1001]; +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + cin >> n; + + for (int i = 0; i < n; i++) { + cin >> num; + auto lowerPos = lower_bound(lis, lis + len, num); + if (*lowerPos == 0) { + len++; + } + *lowerPos = num; + } + + cout << len << '\n'; + return 0; +} diff --git "a/weekly/week02/PGS_\354\244\204\354\204\234\353\212\224\353\260\251\353\262\225/gyuhyeok99.cpp" "b/weekly/week02/PGS_\354\244\204\354\204\234\353\212\224\353\260\251\353\262\225/gyuhyeok99.cpp" new file mode 100644 index 0000000..afbab0c --- /dev/null +++ "b/weekly/week02/PGS_\354\244\204\354\204\234\353\212\224\353\260\251\353\262\225/gyuhyeok99.cpp" @@ -0,0 +1,30 @@ +#include +#include +using namespace std; + +vector answer; +vector numbers; +vector dp; + +vector solution(int n, long long k) { + dp.resize(n); + dp[0] = 1; + for (int i = 1; i < n; i++) { + dp[i] = dp[i-1] * i; + } + + for (int i = 1; i <= n; i++) { + numbers.push_back(i); + } + + k--; + + for (int i = 0; i < n; i++) { + long long idx = k / dp[n-1-i]; + answer.push_back(numbers[idx]); + numbers.erase(numbers.begin() + idx); + k %= dp[n-1-i]; + } + + return answer; +}