호빵이의 알고리즘
[1931번] 회의실배정 본문
#include#include using namespace std; int N; pair P[100000]; int ans = 1; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> P[i].second >> P[i].first; } sort(P, P + N); int end = P[0].first; for (int i = 1; i < N; i++) { if (P[i].second >= end) { end = P[i].first; ans++; } } cout << ans; return 0; }
'알고리즘 > BOJ' 카테고리의 다른 글
[삼성SW테스트] 드래곤 커브 (0) | 2018.08.06 |
---|---|
[14501번] 퇴사 (0) | 2018.08.06 |
[2331번] 반복수열 (0) | 2018.07.30 |
[10825] 국영수 (0) | 2018.07.30 |
[1992번] 쿼드트리 (0) | 2018.07.26 |