https://school.programmers.co.kr/learn/courses/30/lessons/42885
def solution(people, limit):
people.sort()
answer = 0
s, e = 0, len(people)-1
while s <= e:
if people[s] + people[e] <= limit: s += 1
e -= 1
answer += 1
return answer
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int solution(vector<int> people, int limit) {
int answer = 0;
int start = 0, end = people.size()-1;
sort(people.begin(), people.end());
while (start <= end) {
if (people[start] + people[end] <= limit) {start++;}
end--;
answer++;
}
return answer;
}