-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14501.java
More file actions
40 lines (27 loc) · 852 Bytes
/
14501.java
File metadata and controls
40 lines (27 loc) · 852 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
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] t = new int[n];
int[] p = new int[n];
for(int i=0; i<n; i++) {
t[i] = sc.nextInt();
p[i] = sc.nextInt();
}
work(n, t, p, 0, 0);
System.out.println(max);
}
public static int max = 0;
public static void work(int n, int[] t, int[] p, int today, int profit) {
if(today == n) {
if(max < profit) {
max = profit;
}
return;
}
if(today + t[today] <= n) // 상담완료일이 퇴사일을 넘지 않을때만 오늘의 상담실시
work(n, t, p, today + t[today], profit + p[today]);
work(n, t, p, today + 1, profit);
}
}