[BOJ] 14501번 : 퇴사
2024. 9. 2. 19:54ㆍAlgorithm
1. problem :
https://www.acmicpc.net/problem/14501
2. solution 1 :
#include <bits/stdc++.h>
using namespace std;
int n;
int t[20];
int p[20];
int d[20];
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> t[i] >> p[i];
for (int i = n; i >= 1; i--) {
if (t[i] + i <= n + 1) {
d[i] = max(d[i + t[i]] + p[i], d[i + 1]);
}
else d[i] = d[i + 1];
}
cout << *max_element(d, d + n + 1) << '\n';
}
source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/14501.cpp
basic-algo-lecture/0x10/solutions/14501.cpp at master · encrypted-def/basic-algo-lecture
바킹독의 실전 알고리즘 강의 자료. Contribute to encrypted-def/basic-algo-lecture development by creating an account on GitHub.
github.com
'Algorithm' 카테고리의 다른 글
| [BOJ] 9251번 : LCS (0) | 2024.09.03 |
|---|---|
| [BOJ] 10844번 : 쉬운 계단 수 (0) | 2024.09.03 |
| [BOJ] 9461번 : 파도반 수열 (1) | 2024.09.02 |
| [BOJ] 11053번 : 가장 긴 증가하는 부분 수열 (1) | 2024.09.02 |
| [BOJ] 11055번 : 가장 큰 증가하는 부분 수열 (0) | 2024.09.02 |