프로그래머스 135808 과일 장수

Jmnote (토론 | 기여)님의 2023년 11월 26일 (일) 11:06 판

1 개요

프로그래머스 135808 과일 장수

2 C++

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int solution(int k, int m, vector<int> score) {
    sort(score.begin(), score.end(), greater<int>());
    int answer = 0;
    for(int i=0; i<score.size()/m; i++) {
        answer += m * score[i*m+m-1];
    }
    return answer;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}