File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments