]> Skullheadx's Git Forge - CCC.git/commitdiff
2015 S3
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 20:51:46 +0000 (15:51 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 20:51:46 +0000 (15:51 -0500)
.gitignore
Main/C++/2015/S3.cpp [new file with mode: 0644]

index 12e39a0fe986b3c7989aad74748679372e6c70f9..fd027b56c913e8a41ee35953af843dda54c1037a 100644 (file)
@@ -2,3 +2,5 @@
 *.iml
 
 *.iml
+*.o
+*.exe
diff --git a/Main/C++/2015/S3.cpp b/Main/C++/2015/S3.cpp
new file mode 100644 (file)
index 0000000..010a725
--- /dev/null
@@ -0,0 +1,45 @@
+#include <bits/stdc++.h>
+using namespace std;
+
+int main()
+{
+    int G,P,counter=0,g;
+    bool closed = false,can_land = false;
+    cin >> G;
+    cin >> P;
+    bool docks[G] = {};
+//    for (int i = 0; i < G; i++)
+//    {
+//        cout << docks[i] << ' ';
+//    }
+//    cout << endl;
+    for (int i = 0; i < P;i++)
+    {
+        cin >> g;
+        if (!closed)
+        {
+            can_land = false;
+            for (int d = g; d > 0; d--)
+            {
+                if (docks[d-1] == false)
+                {
+                    docks[d-1] = true;
+                    can_land = true;
+                    break;
+                }
+            }
+            if (!can_land)
+            {
+                closed = true;
+            }
+            else
+            {
+                counter++;
+            }
+        }
+    }
+    cout << counter;
+
+
+    return 0;
+}