문제 링크
내 풀이
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int su1 [5] = {1, 2, 3, 4, 5};
int su2 [8] = {2, 1, 2, 3, 2, 4, 2, 5};
int su3 [10] = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5};
vector<int> solution(vector<int> answers) {
vector<int> answer;
vector<int> corr(0);
int po1, po2, po3, a, b, c = 0;
for(int i=0; i < 5; i++){
if(answers[i] == su1[po1]) a++;
if(answers[i] == su2[po2]) b++;
if(answers[i] == su3[po3]) c++;
po1++;
po2++;
po3++;
if(po1 > 4) po1=0;
if(po2 > 7) po2=0;
if(po3 > 9) po3=0;
}
corr.push_back(a);
corr.push_back(b);
corr.push_back(c);
auto valmax = *max_element(corr.begin(), corr.end());
if(valmax==corr.at(0)) answer.push_back(1);
if(valmax==corr.at(1)) answer.push_back(2);
if(valmax==corr.at(2)) answer.push_back(3);
sort(answer.begin(), answer.end());
return answer;
}