Skip to content

Commit 265007a

Browse files
authored
Merge pull request #678 from AlgorithmWithGod/suyeun84
[20250817] BOJ / G5 / 내일 할거야 / 김수연
2 parents 1f9ad39 + 10db255 commit 265007a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class boj7983 {
6+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
static StringTokenizer st;
8+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9+
static int nextInt() {return Integer.parseInt(st.nextToken());}
10+
static StringBuilder sb = new StringBuilder();
11+
12+
public static void main(String[] args) throws Exception {
13+
nextLine();
14+
int n = nextInt();
15+
Task[] task = new Task[n];
16+
for (int i = 0; i < n; i++) {
17+
nextLine();
18+
int d = nextInt();
19+
int t = nextInt();
20+
task[i] = new Task(d, t);
21+
}
22+
Arrays.sort(task, (o1, o2) -> {
23+
return o2.end - o1.end;
24+
});
25+
26+
int answer = task[0].end;
27+
for(int i = 0; i < n; i++) {
28+
if(task[i].end <= answer) answer = task[i].end - task[i].time;
29+
else answer -= task[i].time;
30+
}
31+
System.out.println(answer);
32+
}
33+
static class Task {
34+
int time, end;
35+
public Task(int time, int end) {
36+
this.time = time;
37+
this.end = end;
38+
}
39+
}
40+
}
41+
```

0 commit comments

Comments
 (0)