]> Skullheadx's Git Forge - CCC.git/commitdiff
2014 S3
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 20:52:44 +0000 (15:52 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 20:52:44 +0000 (15:52 -0500)
Main/Python/2014/S3.py [new file with mode: 0644]

diff --git a/Main/Python/2014/S3.py b/Main/Python/2014/S3.py
new file mode 100644 (file)
index 0000000..f7086d3
--- /dev/null
@@ -0,0 +1,32 @@
+T = int(input())
+for test in range(T):
+    N = int(input())
+    order = []
+    for i in range(N):
+        car = int(input())
+        order.append(car)
+
+    branch = []
+    next_ingredient = 1
+
+    while True:
+        if len(branch) == 0 and len(order) == 0:
+            print("Y")
+            break
+
+
+        if len(order) > 0 and next_ingredient == order[-1]:
+            next_ingredient += 1
+            del order[-1]
+        elif len(branch) > 0 and branch[-1] == next_ingredient:
+            next_ingredient += 1
+            del branch[-1]
+        else:
+            if len(order) > 0:
+                branch.append(order[-1])
+                del order[-1]
+            else:
+                print("N")
+                break
+
+