-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBj10818.java
More file actions
33 lines (31 loc) · 871 Bytes
/
Bj10818.java
File metadata and controls
33 lines (31 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.*;
public class Bj10818 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
int[] num = new int[N];
for (int i=0; i<N;i++){
num[i]=sc.nextInt();
}
for (int i=0; i<N; i++){
if (num[i]<=-1000000&&num[i]>=1000000){
break;
}
a[i]=num[i];
}
int resultMax=a[0];
for (int i=0; i<N-1; i++){
if (resultMax<a[i+1]) {
resultMax = a[i + 1];
}
}
int resultMin=a[0];
for (int i=0; i<N-1; i++){
if (resultMin>a[i+1]){
resultMin=a[i+1];
}
}
System.out.println(resultMin +" "+ resultMax);
}
}