Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- UnrealMP
- 백준 1253번
- 언리얼 플러그인
- Linux
- 민겸수
- 5639
- oracle
- 1253번
- 셰그먼트트리
- UActor
- 2단계로킹
- 백준
- FBX
- Security
- 실습
- Unreal
- 오손데이터읽기
- 트랜잭션 관리
- OS
- 의미와 무의미의 경계에서
- hackerank
- 1759번
- SQL
- 언리얼 커스텀 플러그인
- command not found
- C++
- 데이터베이스 배움터
- 1967번
- objtofbx
- 비재귀셰그먼트
Archives
- Today
- Total
fatalite
C++ / 구명보트 본문
Problem
난이도 : 프로그래머스 2단계 68%
분류 : Greedy
Solution
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int solution(vector<int> people, int limit) {
int answer = 0;
sort(people.begin(),people.end(),greater<int>());
int left = 0;
int right = people.size() - 1;
while(left <= right){
while(people[left] + people[right] > limit && left <= right){
left++;
answer++;
}
if(left <= right){
right--;
left++;
answer++;
}
}
return answer;
}
'코딩 인터뷰 > 프로그래머스' 카테고리의 다른 글
C++ / N개의 최소 공배수 구하기 (0) | 2023.05.10 |
---|---|
C++ / 예상대진표 (0) | 2023.05.09 |
C++ / 카펫 (0) | 2023.05.07 |
C++ / 영어 끝말잇기 (0) | 2023.05.07 |
C++ / 숫자의 표현 (0) | 2023.04.24 |