[백준/BOJ] 1449. 수리공 항승 [Silver 3]

jychan99·2021년 11월 3일
0
post-thumbnail
  1. 수리공 항승

문제출처 : https://www.acmicpc.net/problem/1449

시험도 끝났겠다 이제 꾸준히해서 골드찍어보자!!!!

code

#include <stdio.h>
int main()
{
	int i, N, L, W, pipe[1001] = { 0 }, count = 0;
	scanf("%d %d", &N, &L);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &W);
		pipe[W] = 1;
	}
	for (i = 1; i <= 1000; i++)
	{
		if (pipe[i])
		{
			for (int j = 0; j < L; j++)
			{
				if (i + j > 1000)
					break;
				pipe[i + j] = 0;
			}
			count++;
		}
		else
			continue;
	}
	printf("%d", count);
	return 0;
}
profile
내가 지금 두려워 하고 있는 일이 바로 내가 지금 해야 할 일이다. 🐥

0개의 댓글