Skip to content

Commit 679154f

Browse files
authored
Merge pull request #2007 from AlgorithmWithGod/JHLEE325
[20260309] BOJ / G4 / 작업 / 이준희
2 parents 084e705 + e289806 commit 679154f

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
int N = Integer.parseInt(br.readLine());
9+
10+
int[] dp = new int[N + 1];
11+
int res = 0;
12+
13+
for (int i = 1; i <= N; i++) {
14+
StringTokenizer st = new StringTokenizer(br.readLine());
15+
16+
int time = Integer.parseInt(st.nextToken());
17+
int count = Integer.parseInt(st.nextToken());
18+
19+
int prevTask = 0;
20+
for (int j = 0; j < count; j++) {
21+
int prev = Integer.parseInt(st.nextToken());
22+
prevTask = Math.max(prevTask, dp[prev]);
23+
}
24+
25+
dp[i] = prevTask + time;
26+
27+
res = Math.max(res, dp[i]);
28+
}
29+
30+
System.out.println(res);
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)