백준 알고리즘 1931번 문제
문제 : https://www.acmicpc.net/problem/1931
풀이 :
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int value[10];
int main()
{
int N, end, begin;
vector<pair<int, int>> schedule;
cin >> N; //회의실 수
for (int i = 0; i < N; i++) //시작과 끝 시간 입력
{
cin >> begin >> end;
schedule.push_back(make_pair(end, begin));
}
sort(schedule.begin(), schedule.end());
int time = schedule[0].first;
int count = 1;
for (int i = 1; i < N; i++)
{
if (time <= schedule[i].second)
{
count++;
time = schedule[i].first;
}
}
cout << count;
}