- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14501.java
More file actions
Latest commit
40 lines (27 loc) · 852 Bytes
/
Copy path14501.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
importjava.util.*;
publicclassMain {
publicstaticvoidmain(String[] args) {
Scannersc = newScanner(System.in);
intn = sc.nextInt();
int[] t = newint[n];
int[] p = newint[n];
for(inti=0; i<n; i++) {
t[i] = sc.nextInt();
p[i] = sc.nextInt();
}
work(n, t, p, 0, 0);
System.out.println(max);
}
publicstaticintmax = 0;
publicstaticvoidwork(intn, int[] t, int[] p, inttoday, intprofit) {
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);
}
}