웅재의 코딩세상
[프로그래머스] 전국 대회 선발 고사 본문
- 풀이
#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];
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] PCCE 기출문제 1번 (0) | 2024.02.09 |
---|---|
[프로그래머스] 정수를 나선형으로 배치하기 (0) | 2024.02.08 |
[프로그래머스] 정사각형으로 만들기 (0) | 2024.02.03 |
[프로그래머스] 그림 확대 (0) | 2024.02.03 |
[프로그래머스] 무작위로 k개의 수 뽑기 (0) | 2024.02.02 |