From ceec50999f225f0590cd3cee474265876a04406c Mon Sep 17 00:00:00 2001 From: wanderer-s Date: Tue, 10 May 2022 00:20:08 +0900 Subject: [PATCH] problem_b python solution --- chapter02/problem_b/solution.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 chapter02/problem_b/solution.py diff --git a/chapter02/problem_b/solution.py b/chapter02/problem_b/solution.py new file mode 100644 index 0000000..3e934e8 --- /dev/null +++ b/chapter02/problem_b/solution.py @@ -0,0 +1,16 @@ +def is_ordered(data, n): + for i in range(n - 1, 0, -1): + if data[i-1] > data[i]: + return False + + return True + + +if __name__ == "__main__": + n = int(input()) + data = [ int(w) for w in input().split() ] + result = is_ordered(data, n) + if result : + print("YES") + else: + print("NO")