-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11536.java
More file actions
82 lines (69 loc) · 1.92 KB
/
11536.java
File metadata and controls
82 lines (69 loc) · 1.92 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package algo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class Main {
private static int N;
private static String[] str;
public static void main(String[] args) throws IOException {
InputClass.input();
InputClass.BW.write(new Solution().run());
InputClass.close();
}
static class InputClass {
public static final BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
public static final BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out));
private static StringTokenizer st = null;
public static void input() throws IOException {
st = getStringTokenizer();
N = Integer.parseInt(st.nextToken());
str = new String[N];
for(int i=0; i<N; i++) {
st = getStringTokenizer();
str[i] = st.nextToken();
}
}
public static void close() throws IOException {
BR.close();
BW.close();
}
public static StringTokenizer getStringTokenizer() throws IOException {
return new StringTokenizer(InputClass.BR.readLine(), " ");
}
}
static class Solution {
public String run() {
String[] origin = Arrays.stream(str).toArray(String[]::new);
if(isIncreasing(origin)) {
return "INCREASING";
} else if(isDecreasing(origin)) {
return "DECREASING";
} else {
return "NEITHER";
}
}
private boolean isIncreasing(String[] origin) {
Arrays.sort(str);
int len = str.length;
for(int i=0; i<len; i++) {
if(!str[i].equals(origin[i]))
return false;
}
return true;
}
private boolean isDecreasing(String[] origin) {
Arrays.sort(str, Collections.reverseOrder());
int len = str.length;
for(int i=0; i<len; i++) {
if(!str[i].equals(origin[i]))
return false;
}
return true;
}
}
}