Gidhub BE Developer

[BOJ] 10815. 숫자 카드

2018-09-26
goodGid

Problem

Problem URL : 숫자 카드


[1] Answer Code (18. 09. 26)

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    vector<int> v;
    int n;
    cin >> n;
    while (n--) {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    
    cin >> n;
    while (n--) {
        int tmp;
        cin >> tmp;
        if(binary_search(v.begin(), v.end(), tmp))
            cout << "1" << " ";
        else
            cout << "0" << " ";
    }
    return 0;
}

Review

  • 노코멘트.

Recommend

Index