Created
December 9, 2017 21:06
-
-
Save Trimad/e867740076264fb443c830080142817c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class KattisA { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int N = sc.nextInt(); | |
boolean incr = false; | |
boolean decr = false; | |
ArrayList<String> al = new ArrayList(); | |
for (int i = 0; i <= N; i++) { | |
al.add(sc.nextLine()); | |
} | |
for (int i = 1; i < al.size() - 1; i++) { | |
//Increasing | |
if (al.get(i).charAt(0) < al.get(i + 1).charAt(0)) { | |
incr = true; | |
} | |
//Decreasing | |
if (al.get(i).charAt(0) > al.get(i + 1).charAt(0)) { | |
decr = true; | |
} | |
//If the first characters are equal, check the next character | |
if (al.get(i).charAt(0) == al.get(i + 1).charAt(0)) { | |
//Increasing | |
if (al.get(i).charAt(1) < al.get(i + 1).charAt(1)) { | |
incr = true; | |
} | |
//Decreasing | |
if (al.get(i).charAt(1) > al.get(i + 1).charAt(1)) { | |
decr = true; | |
} | |
} | |
} | |
if (decr && !incr) { | |
System.out.println("DECREASING"); | |
} else if (!decr && incr) { | |
System.out.println("INCREASING"); | |
} else if ((incr && decr) || (!incr & !decr)) { | |
System.out.println("NEITHER"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment