Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <algorithm>
- #include <iostream>
- #include <vector>
- using namespace std;
- vector<int> solution(vector<int> answers) {
- vector<int> answer;
- pair<int, int> tmp;
- pair<int, int> myInfo[3] = {{1,0}, {2,0}, {3,0}};
- int problemSize = answers.size();
- int how_1[] = { 0,1,2,3,4,5 };
- int how_2[] = { 0,2,1,2,3,2,4,2,5 };
- int how_3[] = { 0,3,3,1,1,2,2,4,4,5,5 };
- for (int i = 0; i<problemSize; i++) {
- if (i % 5 == 0) {
- idx_1 = 1;
- }
- if (i % 8 == 0) {
- idx_2 = 1;
- }
- if (i % 10 == 0) {
- idx_3 = 1;
- }
- if (how_1[idx_1] == answers[i]) {
- myInfo[0].second++;
- }
- if (how_2[idx_2] == answers[i]) {
- myInfo[1].second++;
- }
- if (how_3[idx_3] == answers[i]) {
- myInfo[2].second++;
- }
- idx_1++;
- idx_2++;
- idx_3++;
- }
- for(int i = 0; i< 2; i++){
- for(int j = 0; j<2-i; j++){
- if(myInfo[j].second < myInfo[j+1].second){
- tmp = myInfo[j];
- myInfo[j] = myInfo[j+1];
- myInfo[j+1] = tmp;
- }
- }
- }
- answer.push_back(myInfo[0].first);
- if (myInfo[0].second == myInfo[1].second) {
- answer.push_back(myInfo[1].first);
- if (myInfo[1].second == myInfo[2].second)
- answer.push_back(myInfo[2].first);
- }
- return answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement