Little Jay

[C++] 백준 1453번 - 피시방 알바 본문

알고리즘/BOJ

[C++] 백준 1453번 - 피시방 알바

Jay, Lee 2021. 8. 7. 20:18

동적 배열로 풀면 안되는 문제인 것 같다. 

그냥 배열로 풀어야 정답으로 서버가 인정하는 것 같다.

 

#include <iostream>
using namespace std;

int main() {

	int n;
	cin >> n;
	
	int arr[101] = { 0, };
	int x;
	int denied = 0;

	for (int i = 0; i < n; i++) {
		cin >> x;
		if (arr[x] == 1)
			denied++;
		else
			arr[x] = 1;
	}

	cout << denied << "\n";

	return 0;

}
Comments