From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Sat, 19 Nov 2022 20:51:46 +0000 (-0500) Subject: 2015 S3 X-Git-Url: http://git.skullheadx.com/life/index.html?a=commitdiff_plain;h=c618331ea4fb322d4554007be11d345833c9482c;p=CCC.git 2015 S3 --- 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; +}