문제 링크

 

 

CPP

#include <bits/stdc++.h>
using namespace std;

int n,m,a,b;
vector<int> v;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n; //5
    
    for(int i=0; i<n;i++) {
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(),v.end());
    cin>>m;  
    for(int j=0; j<m;j++){
      cin >> b;
      if (binary_search(v.begin(),v.end(),b)) {
        cout << 1<< " ";
        }
      else cout << 0 << " ";

    }
}

'CPP 문제풀이 > 백준' 카테고리의 다른 글

백준 1026번 : 보물  (0) 2020.09.22
백준 10845번 : 큐  (0) 2020.09.22
백준 10989번 : 수 정렬하기 3  (0) 2020.09.18
백준 1920번 : 수 찾기  (0) 2020.09.17
알고리즘 길라잡이 따라 풀기 - 3  (0) 2020.09.14
블로그 이미지

hjc_

୧( “̮ )୨

,