first commit

This commit is contained in:
Nyagami
2022-12-15 23:51:04 +07:00
commit 87d51fb251
292 changed files with 12623 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import java.util.*;
import java.io.*;
public class Main {
static class pair{
public int first, second;
public pair(int a, int b){
first = a;
second = b;
}
}
public static void main(String[] args) throws IOException, ClassNotFoundException {
// Scanner sc = new Scanner(new File("ONLINE.in"));
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<pair> a = new ArrayList<>();
for(int i=0;i<n;i++) a.add(new pair(sc.nextInt(), sc.nextInt()));
a.sort((pair x, pair b) -> {
return x.first - b.first;
});
int now = 0;
for(int i=0;i<n;i++){
if(a.get(i).first>=now) now=a.get(i).first+a.get(i).second;
else now+=a.get(i).second;
}
System.out.println(now);
}
}