From 795bdc8586398e667cf9885efb03d623cc0c93d0 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 22 Dec 2024 17:34:10 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=8A=88=20#415=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=86=94=EB=A3=A8=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\235\230\352\263\240\354\202\254.cpp" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "Programmers/\353\252\250\354\235\230\352\263\240\354\202\254.cpp" diff --git "a/Programmers/\353\252\250\354\235\230\352\263\240\354\202\254.cpp" "b/Programmers/\353\252\250\354\235\230\352\263\240\354\202\254.cpp" new file mode 100644 index 0000000..388179c --- /dev/null +++ "b/Programmers/\353\252\250\354\235\230\352\263\240\354\202\254.cpp" @@ -0,0 +1,29 @@ +#include +#include + +using namespace std; + +vector solution(vector answers) { + vector student1 = {1, 2, 3, 4, 5}; + vector student2 = {2, 1, 2, 3, 2, 4, 2, 5}; + vector student3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; + + vector scores(3, 0); + + for (int i = 0; i < answers.size(); ++i) { + if (answers[i] == student1[i % student1.size()]) ++scores[0]; + if (answers[i] == student2[i % student2.size()]) ++scores[1]; + if (answers[i] == student3[i % student3.size()]) ++scores[2]; + } + + int maxScore = *max_element(scores.begin(), scores.end()); + + vector result; + for (int i = 0; i < scores.size(); ++i) { + if (scores[i] == maxScore) { + result.push_back(i + 1); + } + } + + return result; +} \ No newline at end of file