알고리즘/SW Expert Academy

[D5] 8191. 만화책 정렬하기

혬혬 2019. 10. 6. 11:10
728x90
#include <stdio.h>

int main() {

	int test_case = 0;
	scanf("%d", &test_case);
	char buffer = 0;
	scanf("%c", &buffer);

	for (int q = 0; q < test_case; q++) {
		int test_amount = 0;
		scanf("%d", &test_amount);
		int box = 0;
		int m[200002] = { 0 };
		int memory_point = 0;
		for (int i = 0; i < test_amount; i++) {
			scanf("%d", &box);
			if (m[box-1] == 1) {
				m[box] = 1;
			}
			else {
				m[box] = 1;
				memory_point++;
			}
		}
		printf("#%d %d\n", q + 1, memory_point);
		memory_point = 0;
	}

	return 0;
}
728x90