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 | 31 |
Tags
- C++
- 호스트 주소
- InsertRange
- list 사용법
- list
- C# Contains
- 네트워크
- 서브넷 마스크
- AddRange
- 백준
- 네트워크 용어
- DP
- 알고리즘
- 호스트
- c#
- OSI 3계층
- 기본 게이트웨이
- Parse 사용법
- List 찾기
- 서브넷
- Visual Studio
- IP주소
- Tostring 사용법
- List 정렬
- TCP/IP
- List 제거
- c# list
- List 추가
- BFS
- C# Find
Archives
- Today
- Total
CodeLabs
[백준 / C#] 1931 : 회의실 배정 본문
using System;
using System.Linq;
class Program
{
static int n;
static int result = 1;
static void Input()
{
n = int.Parse(Console.ReadLine());
}
static void Solution()
{
int[][] meeting_time = new int[n][];
for (int i = 0; i < n; i++)
{
var input = Console.ReadLine().Split();
int[] copy = new int[2];
copy[0] = int.Parse(input[0]);
copy[1] = int.Parse(input[1]);
meeting_time[i] = copy;
}
// 가변배열 열정렬
IOrderedEnumerable<int[]> sortedBySecond = meeting_time.OrderBy(y => y[1]).ThenBy(y=> y[0]);
meeting_time = sortedBySecond.ToArray();
Compare(meeting_time, 0);
Console.WriteLine(result);
}
static void Compare(int[][] arr, int index)
{
int left = 0;
int right = 1;
while (right < n)
{
int[] leftArr = arr[left];
int[] nextArr = arr[right];
if (leftArr[1] > nextArr[0])
right++;
else
{
leftArr = nextArr;
left=right++;
result++;
}
}
}
static void Solve()
{
Input();
Solution();
}
static void Main(string[] args)
{
Solve();
}
}
'백준 > 1000 ~' 카테고리의 다른 글
[백준 / C#] 2579 : 계단 오르기 (0) | 2023.07.30 |
---|---|
[백준 / C#] 2178 : 미로탐색 (0) | 2023.07.28 |
[백준 / C#] 1927 : 최소 힙 (0) | 2023.07.24 |
[백준 / C++] 1764 : 듣보잡 (0) | 2023.07.21 |
[백준 / C#] 1697 : 숨바꼭질 (0) | 2023.07.18 |