소스 코드
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int solution(vector<int> people, int limit) {
int answer = 0;
int n = people.size();
sort(people.begin(), people.end());
int result = limit;
int cnt = 1;
int tail = 0; //제일작은
int head = n - 1; //제일큰
while (head >= tail) {
result = limit;
if (people[head] + people[tail] <= result) {
tail++;
head--;
}
else {
head--;
}
cnt++;
}
return answer;
}
int main() {
solution({ 70,50,80,50 }, 100);
return 0;
}