-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Solution.java
38 lines (34 loc) · 956 Bytes
/
Solution.java
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
34
35
36
37
38
// github.com/RodneyShag
import java.util.Scanner;
// Time complexity: O(n)
public class Solution {
public static void main(String[] args) {
/* Save input */
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] scores = new int[n];
for (int i = 0; i < n; i++) {
scores[i] = scan.nextInt();
}
scan.close();
/* Calculate answer */
printRecords(scores);
}
static void printRecords(int[] scores){
int min = scores[0];
int max = scores[0];
int higherScore = 0;
int lowerScore = 0;
for (int score: scores) {
if (score > max) {
max = score;
higherScore++;
}
if (score < min) {
min = score;
lowerScore++;
}
}
System.out.print(higherScore + " " + lowerScore);
}
}