Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

모의고사 #415

Closed
Tracked by #396
fkdl0048 opened this issue Nov 26, 2024 · 0 comments
Closed
Tracked by #396

모의고사 #415

fkdl0048 opened this issue Nov 26, 2024 · 0 comments
Assignees
Milestone

Comments

@fkdl0048
Copy link
Owner

fkdl0048 commented Nov 26, 2024

#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> answers) {
    vector<int> student1 = {1, 2, 3, 4, 5};
    vector<int> student2 = {2, 1, 2, 3, 2, 4, 2, 5};
    vector<int> student3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5};

    vector<int> 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<int> result;
    for (int i = 0; i < scores.size(); ++i) {
        if (scores[i] == maxScore) {
            result.push_back(i + 1);
        }
    }

    return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

1 participant