Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 프로그래머스 #c++ #코딩테스트
- 프로그래머스 #sql #mysql #코딩테스트
- 백준 #백준알고리즘 #알고리즘 #코딩테스트 #코딩테스트준비 #코테준비 #백준2110 #python #문제풀이
- 프로그래머스 #NULL 처리하기
- 카카오 #프로그래머스 #python #코딩테스트 #오픈채팅방
- 프로그래머스 #네트워크 #c++ #코딩테스트 #코테 #코테준비 #dfs
- 백준 #백준2217 #백준로프 #python
- 프로그래머스 #python #2021카카오 #카카오코테 #카카오인턴쉽
- 그리디알고리즘 #그리디 #백준 #우선순위큐 #최소힙 #최대힙 #알고리즘 #코딩테스트 #python
- 프로그래머스 #python #코딩테스트 #코테공부 #알고리즘 #dict
- 백준 #이거다시풀기
- 동
- 카카오 코테
Archives
- Today
- Total
say repository
[프로그래머스] 모의고사 c++ 본문
728x90
https://programmers.co.kr/learn/courses/30/lessons/42840
출처: 프로그래머스
코딩테스트 연습 - 모의고사
수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는
programmers.co.kr
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//수포자 3명 규칙
int p1[5] = {1,2,3,4,5};
int p2[8] = {2,1,2,3,2,4,2,5};
int p3[10] = {3,3,1,1,2,2,4,4,5,5};
vector<int> solution(vector<int> answers) {
vector<int> answer;
vector<int> score = {0,0,0};
int max_score = 0;
//완전 탐색
for(int i=0; i<answers.size();i++){
if (answers[i] == p1[i%5])
score[0]++;
if (answers[i] == p2[i%8])
score[1]++;
if (answers[i] == p3[i%10])
score[2]++;
}
//max_score = max(max(score[0],score[1]), score[2]);
max_score = *max_element(score.begin(), score.end());
for(int i=0; i<score.size();i++){
if (score[i] == max_score){
answer.push_back(i+1);
}
}
return answer;
}
'알고리즘 문제 풀이 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 카펫 c++ (0) | 2022.03.17 |
---|---|
[프로그래머스] 소수 찾기 c++ (0) | 2022.03.17 |
[프로그래머스] 우유와 요거트가 담긴 장바구니 mysql (*) (0) | 2022.02.11 |
[프로그래머스] 헤비 유저가 소유한 장소 MYSQL (*) (0) | 2022.02.11 |
[프로그래머스] 보호소에서 중성화한 동물 mysql (*) (0) | 2022.02.11 |