Skip to content

Commit 99bfcf8

Browse files
committed
Record Breaker
KS 2020 D-1 / Array Sort / AC / 2021.01.01
1 parent e53c0a7 commit 99bfcf8

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Owen's Algorithm Problem Solving Note
88

99
#### Round D
1010

11+
1. Record Breaker / Array Sort / AC / 2021.01.01
12+
1113
#### Round E
1214

1315
#### Round F

src/Kickstart_2020_D_1.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
import java.io.*;
2+
import java.util.*;
3+
14
public class Kickstart_2020_D_1 {
2-
public static void main(String[] args) {
3-
System.out.println("Hello World");
5+
public static void main(String[] args) throws IOException {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
StringTokenizer st = new StringTokenizer(br.readLine());
8+
int T = Integer.parseInt(st.nextToken());
9+
for (int i = 1; i <= T; i++) {
10+
int N = Integer.parseInt(br.readLine());
11+
int[] arr = new int[N];
12+
int max = -1;
13+
st = new StringTokenizer(br.readLine());
14+
int cnt = 0;
15+
for (int j = 0; j < N; j++) {
16+
arr[j] = Integer.parseInt(st.nextToken());
17+
}
18+
for (int j = 0; j < N; j++) {
19+
if(j == N-1) {
20+
if(arr[j] > max) cnt++;
21+
} else {
22+
if(arr[j] > max && arr[j] > arr[j+1]) cnt++;
23+
}
24+
max = Math.max(arr[j], max);
25+
}
26+
System.out.println("Case #" + i + ": " + cnt);
27+
}
428
}
529
}

0 commit comments

Comments
 (0)