import java.util.Arrays;
class Solution {
public int solution(int[] people, int limit) {
int answer = 0;
Arrays.sort(people);
if(people[0]+people[1]>limit){
return people.length;
}
int first =0;
int last = people.length-1;
while(first<=last){
if(people[first]+people[last] <= limit){
answer+= 1;
first +=1;
last -=1;
}else{
answer+=1;
last -=1;
}
}
return answer;
}
}