-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJAEHEE25.java
More file actions
32 lines (28 loc) · 976 Bytes
/
JAEHEE25.java
File metadata and controls
32 lines (28 loc) · 976 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
package week02.BOJ_15486_퇴사2;
import java.util.*;
import java.lang.*;
import java.io.*;
class BOJ15486 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int[] T = new int[N];
int[] P = new int[N];
for (int i = 0; i < N; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
int t = Integer.parseInt(st.nextToken());
int p = Integer.parseInt(st.nextToken());
T[i] = t;
P[i] = p;
}
int max = 0;
int[] dp = new int[N + 1];
for (int i = 0; i < N; i++) {
max = Math.max(dp[i], max);
if (i + T[i] <= N) { //기간 초과 제외
dp[i + T[i]] = Math.max(P[i] + max, dp[i + T[i]]);
}
}
System.out.println(Math.max(dp[N], max));
}
}