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" << '\n';
else
cout << "0" << '\n';
}
return 0;
}
Review
- endl을 사용하니까 시간 초과가 떴다.