//https://www.acmicpc.net/problem/1920 #include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int A[100001]; | |
bool find_x(int x,int start, int end) | |
{ | |
int m; | |
while(end-start>=0){ | |
m=(end+start)/2; | |
if(A[m]==x) return true; | |
if(A[m]<x) start=m+1; | |
else end=m-1; | |
} | |
return false; | |
} | |
int main() | |
{ | |
int N,M; | |
scanf("%d",&N); | |
bool chk=0; | |
for(int i=0; i<N;i++) | |
scanf("%d",A+i); | |
scanf("%d",&M); | |
sort(A,A+N); | |
for(int i=0; i<M; i++) | |
{ | |
chk=0; | |
int x; | |
scanf("%d",&x); | |
chk=find_x(x, 0, N-1); | |
printf("%d\n",chk); | |
} | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180302_9465_스티커 (0) | 2018.03.02 |
---|---|
180301_1931_회의실 배정 (0) | 2018.03.01 |
180228_10430_나머지 (0) | 2018.02.28 |
180227_1008_A/B (0) | 2018.02.27 |
180227_10172_개 (0) | 2018.02.27 |