From c618331ea4fb322d4554007be11d345833c9482c Mon Sep 17 00:00:00 2001 From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:51:46 -0500 Subject: [PATCH] 2015 S3 --- .gitignore | 2 ++ Main/C++/2015/S3.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Main/C++/2015/S3.cpp diff --git a/.gitignore b/.gitignore index 12e39a0..fd027b5 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 0000000..010a725 --- /dev/null +++ b/Main/C++/2015/S3.cpp @@ -0,0 +1,45 @@ +#include +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; +} -- 2.54.0