-
Notifications
You must be signed in to change notification settings - Fork 0
/
직업군_추천하기.cpp
37 lines (36 loc) · 858 Bytes
/
직업군_추천하기.cpp
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
32
33
34
35
36
37
#include <string>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
map<string,map<string,int>> mp;
void split(string str){
vector<string> ret;
int idx;
str+=' ';
while((idx=str.find(' '))!=string::npos){
ret.push_back(str.substr(0,idx));
str=str.substr(idx+1);
}
map<string,int> m;
for(int i=1;i<=5;i++){
m[ret[i]]=6-i;
}
mp[ret[0]]=m;
}
string solution(vector<string> table, vector<string> languages, vector<int> preference) {
string answer = "";
for(auto t : table) split(t);
int mv=0;
for(auto p : mp){
auto job = p.first;
auto tb = p.second;
int v=0;
for(int i=0;i<languages.size();i++) v+=preference[i]*tb[languages[i]];
if(v>mv){
answer = job;
mv=v;
}
}
return answer;
}