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