백준 #1931

김유원·2021년 5월 25일

백준_알고리즘

목록 보기
10/10

백준 알고리즘 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;
}
profile
개발 공부 블로그

0개의 댓글