AcWing 1204. 错误票据
原题链接
简单
作者:
差一点睡死了
,
2021-02-18 09:27:01
,
所有人可见
,
阅读 305
一直报输入错误,还能AC 奇了怪了
import java.util.*;
public class Main {
static int N=100010;
static boolean[] flag=new boolean[N];
static int res1;
static int res2;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int min=Integer.MAX_VALUE;
int max=Integer.MIN_VALUE;
sc.nextLine();
while(n-->0) {
String[] str = sc.nextLine().split(" ");
for (int i = 0; i <str.length; i++) {
// System.out.print(str[i]+" ");
int t = Integer.parseInt(str[i]);
min=Math.min(t, min);
max=Math.max(t, max);
if(flag[t]) res2=t;
flag[t]=true;
}
}
for (int i =min; i <=max; i++) {
if(!flag[i]) {
res1=i;
break;
}
}
System.out.println(res1+" "+res2);
}
}