웅재의 코딩세상

[프로그래머스] 전국 대회 선발 고사 본문

코딩테스트/프로그래머스 - LV 0

[프로그래머스] 전국 대회 선발 고사

웅드 2024. 2. 3. 17:44

 

  • 풀이
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
map<int,int> mp;
int solution(vector<int> rank, vector<bool> attendance) {
    vector<int> v;
    for(int i=0; i<rank.size(); i++){
        if(attendance[i]==true) mp.insert(make_pair(rank[i],i));
    }
    auto it = mp.begin();
    for(int i=0; i<3; i++){
        v.push_back(it->second);
        it++;
    }
    return 10000*v[0] + 100*v[1] + v[2];
}
반응형