일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 머신러닝
- 프로그래머스
- 알고리즘
- LAA
- Deep learning
- zeros
- mpnp
- MATLAB
- cpp
- 컴퓨터과학과
- 선형대수
- 온라인석사
- Plotting
- 매트랩
- 기본
- machine learning
- 딥러닝
- 주정부이민
- 코딩테스트
- LV1
- 조지아텍
- omscs
- 방송통신대학교
- 개발자
- EOI
- 마니토바
- leetcode
- C++
- 캐나다 영주권
- 방통대
Archives
- Today
- Total
Krononberg
프로그래머스 - 직업군 추천하기 C++ 본문
#include <string>
#include <vector>
using namespace std;
string solution(vector<string> table, vector<string> languages, vector<int> preference) {
string answer = "";
vector<string>temp;
int baseScore = 6;
int intermSum = 0;
int highScore = 0;
for (int i = 0; i < table.size(); i++) {
string word = "";
for (int p = 0; p < table[i].size(); p++) {
if (table[i][p] != ' ') {
word += table[i][p];
if (p == table[i].size() - 1)
temp.push_back(word);
}
else {
temp.push_back(word);
word = "";
continue;
}
}
intermSum = 0;
for (int j = 0; j < languages.size(); j++) {
for (int q = 0; q < temp.size(); q++) {
if (temp[q] == languages[j]) {
baseScore -= q;
break;
}
else if (q == temp.size() - 1)
baseScore = 0;
}
intermSum += baseScore * preference[j];
baseScore = 6;
}
if (intermSum > highScore) {
highScore = intermSum;
answer = temp[0];
}
else if (intermSum == highScore) {
if (answer > temp[0])
answer = temp[0];
}
temp.clear();
}
return answer;
}
'개발 로그 > 알고리즘' 카테고리의 다른 글
프로그래머스) 찾아라 프로그래밍 마이스터 c++ (0) | 2021.08.31 |
---|---|
프로그래머스) 완주하지못한 선수 c++ (0) | 2021.08.27 |
크레인 인형뽑기 c++풀이 (0) | 2021.08.23 |
leetcode 1859. Sorting the Sentence.cpp (0) | 2021.06.21 |
프로그래머스 lv2 테스트 2번 :카펫 c++ 풀이 (0) | 2021.06.14 |