프로그래머스 138477 명예의 전당 (1)

1 개요[ | ]

프로그래머스 138477 명예의 전당 (1)

2 C++[ | ]

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> solution(int k, vector<int> score) {
    vector<int> answer;
    vector<int> ranked;
    for(auto &s: score) {
        ranked.push_back(s);
        sort(ranked.begin(), ranked.end(), greater<int>());
        if(ranked.size()>k) ranked.pop_back();
        answer.push_back(ranked.back());
    }
    return answer;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}