import java.util.*;
/**
* 找最小数
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int n = scanner.nextInt();
List<MyPackage> dataList = new ArrayList<>(n);
for (int i = 0; i < n; ++i) {
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
MyPackage myPackage = new MyPackage(num1, num2);
dataList.add(myPackage);
}
Comparator<MyPackage> myPackageComparator = (o1, o2) -> {
if (o1.getNum1() != o2.getNum1()) {
return o1.getNum1() - o2.getNum1();
} else {
return o1.getNum2() - o2.getNum2();
}
};
Collections.sort(dataList, myPackageComparator);
MyPackage result = dataList.get(0);
String formatString = String.format("%d %d", result.getNum1(), result.getNum2());
System.out.println(formatString);
}
}
private static class MyPackage {
private int num1;
private int num2;
public MyPackage(int num1, int num2) {
this.num1 = num1;
this.num2 = num2;
}
public int getNum1() {
return num1;
}
public void setNum1(int num1) {
this.num1 = num1;
}
public int getNum2() {
return num2;
}
public void setNum2(int num2) {
this.num2 = num2;
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
public class Main {
static class pairs {
int x;
int y;
public pairs(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x + " " + y;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<pairs> list = new ArrayList<>();
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
String[] s = br.readLine().split(" ");
pairs p = new pairs(Integer.parseInt(s[0]), Integer.parseInt(s[1]));
list.add(p);
}
list.sort(new Comparator<pairs>() {
@Override
public int compare(pairs o1, pairs o2) {
int sum1 = o1.x - o2.x;
int sum2 = sum1 == 0 ? o1.y - o2.y : sum1;
return sum2;
}
});
System.out.println(list.get(0));
}
}
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
TreeMap<Integer, Integer> map = new TreeMap<>();
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
if (map.get(x)==null) map.put(x,y);
else if (map.get(x)>y) map.put(x,y);
}
Map.Entry<Integer, Integer> entry = map.firstEntry();
System.out.println(entry.getKey()+" "+entry.getValue());
}
} import java.util.Scanner;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int[] nums = new int[2];
nums[0] = sc.nextInt();
nums[1] = sc.nextInt();
int x,y;
for(int i=0;i<n-1;i++){
x=sc.nextInt();
y=sc.nextInt();
if(x<nums[0]){
nums[0]=x;
nums[1]=y;
}else if(x==nums[0]){
if(y<nums[1]){
nums[1]=y;
}
}
}
System.out.println(nums[0]+" "+nums[1]);
}
}
}
额感觉也没什么好说的
就是先找到行值最小值
然后再找行值最小值条件下的列最小值
就用普通数组实现
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
int n = scan.nextInt();
int[][] data = new int[n][2];
for (int i = 0; i < n; i++) {
data[i][0] = scan.nextInt();
data[i][1] = scan.nextInt();
}
int min = data[0][0];
int temp=0;
for (int i = 1; i < n; i++) {
if (data[i][0] < min) {
min = data[i][0];
temp=i;
}
}
int min2 = data[temp][1];
for (int i = 0; i < n; i++) {
if (data[i][0] == min) {
if (data[i][1] < min2) {
min2 = data[i][1];
}
}
}
System.out.println(min + " " + min2);
}
}
}
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
while(input.hasNext()){
int [][] a = new int[1000][2];
int x,y;
int n = input.nextInt();
a[0][0]=x=input.nextInt();
a[0][1]=y=input.nextInt();
for(int i=1;i<n;i++)
{
a[i][0] = input.nextInt();
a[i][1] = input.nextInt();
if(a[i][0]<x)
{
x=a[i][0];
y=a[i][1];
}
else if(a[i][0]==x&&a[i][1]<y)
{
x=a[i][0];
y=a[i][1];
}
}
System.out.println(x+" "+y);
}
input.close();
}
}
import java.util.Scanner;
/**
* Created by fhqplzj on 17-2-19 at 下午8:32.
*/
public class My10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int n = scanner.nextInt();
int min0 = Integer.MAX_VALUE, min1 = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
int b = scanner.nextInt();
if (a < min0 || (a == min0 && b < min1)) {
min0 = a;
min1 = b;
}
}
System.out.println(String.format("%d %d", min0, min1));
}
}
}