백준 10810 c++

magicdrill·2024년 3월 26일
0

백준 문제풀이

목록 보기
210/655

백준 10810 c++

#include <iostream>
using namespace std;
int main(void)
{
	int N, M;
	int* arr = NULL;
	int i, j, k;
	int t, s;

	cin >> N >> M;
	if ((N >= 1 && N <= 100) && (M >= 1 && M <= 100))
	{
		arr = new int[N] {};
		for (t = 0; t < M; t++)
		{
			cin >> i >> j >> k;
			if((i >= 1 && i <= j)&&(j >= 1 && j<= N)&&(k >= 1 && k <= N))
			{
				for (s = i-1; s < j; s++)
				{
					arr[s] = k;
				}
			}
			else
			{
				t--;
			}
		}
		for (s = 0; s < N; s++)
		{
			cout << arr[s] << " ";
		}
		cout << endl;
	}
	else
	{
		;
	}
	delete[] arr;

	return 0;
}

0개의 댓글