프로그래머스/탐욕법(Greedy)
-
[프로그래머스/탐욕법/Lv.1] 체육복프로그래머스/탐욕법(Greedy) 2020. 6. 25. 21:03
문제 설명 코드 #include #include #include using namespace std; int solution(int n, vector lost, vector reserve) { int answer = 0; bool check[31]={false,}; answer = n-lost.size(); if(lost.size()==0 || reserve.size()==0) return answer; sort(lost.begin(),lost.end()); sort(reserve.begin(),reserve.end()); for(int i=0;i