cyphen156
백준-집합과 맵 10815 숫자 카드 본문
N개의 카드 중 M개의 입력에 대해 존재 유무를 찾는 프로그램 작성하기
제약사항
- 0 < N <= 500,000
- -100,000 <= NInput ≤ 100,000
- 0 < M <= 500,000
- -100,000 <= MInput ≤ 100,000
- return Value (Yes :: 1, No :: 0)
주의 사항
없다.
CPP풀이
숫자 카드_10815.cpp
/**
* 백준 숫자 카드_10815
* N개의 카드 중 M개의 입력에 대해 존재 유무를 찾는 프로그램 작성하기
*
* 제한사항
*****************************************
* 0 < N <= 500,000 *
* -100,000 <= NInput ≤ 100,000 *
* 0 < M <= 500,000 *
* -100,000 <= MInput ≤ 100,000 *
* return Value (Yes :: 1, No :: 0) *
*****************************************
*
*
*
* 주의
* 없다.
*
* 풀이시간 5분
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector<int> NInputs;
for (int i = 0; i < N; ++i)
{
int input;
cin >> input;
NInputs.push_back(input);
}
sort(NInputs.begin(), NInputs.end());
int M;
cin >> M;
for (int i = 0; i < M; ++i)
{
int input;
cin >> input;
if (binary_search(NInputs.begin(), NInputs.end(), input))
{
cout << 1;
}
else
{
cout << 0;
}
cout << ' ';
}
cout << endl;
return 0;
}
모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리 에 있습니다.
Workspace/알고리듬 풀이 at main · cyphen156/Workspace
Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.
github.com
'컴퓨터공학 > 알고리듬 풀이' 카테고리의 다른 글
백준-집합과 맵 7785 회사에 있는 사람 (0) | 2025.05.09 |
---|---|
백준-집합과 맵 14425 문자열 집합 (0) | 2025.05.07 |
백준-정렬 좌표 압축 (0) | 2025.04.30 |
백준-정렬 10814 나이순 정렬 (0) | 2025.04.29 |
백준-정렬 1181 단어 정렬 (0) | 2025.04.28 |